我会像打字机一样逐个字符地制作一个 NSString 动画。该字符串将放置在 UILabel 上。有可能吗?如果是,如何?
提前致谢。
更新
woz 的方法效果很好,但我不能用它来解决我的问题。我会试着解释一下我的情况。在我的应用程序的第一个视图中,我会显示实际位置,所以我添加了这些方法:
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
//NSLog(@"didUpdateToLocation: %@", newLocation);
CLLocation *currentLocation = newLocation;
if (currentLocation != nil) {
longitude.text = [NSString stringWithFormat:@"%.3f", currentLocation.coordinate.longitude];
latitude.text = [NSString stringWithFormat:@"%.3f", currentLocation.coordinate.latitude];
}
NSLog(@"Resolving the Address");
[geocoder reverseGeocodeLocation:currentLocation completionHandler:^(NSArray *placemarks, NSError *error) {
//NSLog(@"Found placemarks: %@, error: %@", placemarks, error);
if (error == nil && [placemarks count] > 0) {
placemark = [placemarks lastObject];
[address sizeToFit];
address.text = [NSString stringWithFormat:@"%@, %@\n%@ %@\n%@",
[self sanitizedDescription:placemark.thoroughfare],
[self sanitizedDescription:placemark.subThoroughfare],
[self sanitizedDescription:placemark.postalCode],
[self sanitizedDescription:placemark.locality],
[self sanitizedDescription:placemark.country]];
} else {
NSLog(@"%@", error.debugDescription);
}
} ];
}
- (NSString *)sanitizedDescription:(NSString *)obj
{
if (obj == nil)
{
obj = @"...";
return obj;
}
return obj;
}
现在我会在调用if (obj == nil)
on时使用打字机动画。- (NSString *)sanitizedDescription:(NSString *)obj
我能怎么做?
抱歉,我刚开始使用 Obj-C :(