我扩展了MapKit使用以下代码绘制自定义注释图像的能力:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{
NSLog(@"Drawing a cloud on the map");
MKAnnotationView *view;
if(annotation != mapView.userLocation){
view=[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"parkingloc"];
view.image=[UIImage imageNamed:@"placemarkCloud.png"];
[view setCanShowCallout:YES];
[view setRightCalloutAccessoryView:[UIButton buttonWithType:UIButtonTypeDetailDisclosure]];
}
else{
view=
}
return view;
}
Run Code Online (Sandbox Code Playgroud)
我的问题是我应该如何制作视图=以保留iPhone的内置蓝点.您可以看到我删除了为点绘制的自定义图像,但我不知道如何将其显示为默认值.
我正在使用以下功能激活设备相机或图像选择器,具体取决于UIActionSheet的结果.如果fromCamera = YES则适用于iPhone和iPad.如果fromCamera = NO,那么它适用于iPhone并出现图像选择器.但它在iPad上崩溃时出现以下错误:此设备无法使用UIStatusBarStyleBlackTranslucent. 我已经知道iPad无法显示UIStatusBarStyleBlackTranslucent statusBar,但是如何避免这种崩溃呢?
-(void)addPhotoFromCamera:(BOOL)fromCamera{
if(fromCamera){
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
}
else{
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
[self presentModalViewController:picker animated:YES];
Run Code Online (Sandbox Code Playgroud)
}
我有一个iAd显示在主视图的全屏子视图的顶部.iAd在纵向模式下正常工作,我已将iAd横幅视图的旋转处理为横向模式.用户在横向模式下轻触iAd时会出现此问题.测试广告以纵向,侧面显示在电话上,当用户点击x以关闭iAd时,横幅视图及其父视图被推离屏幕.iAd在纵向模式下正常运行(即点击它并关闭它会导致包含正常显示的横幅的视图).
我尝试过的事情:
- (void)bannerViewActionDidFinish:(ADBannerView *)banner{
NSLog(@"Ad was closed, show the adView again");
if(UIInterfaceOrientationIsLandscape(currentInterfaceOrientation)){
[self animateRotationToLandscape:0.3f];
}
else{
[self animateRotationToPortrait:0.3f];
}
}
-(void)animateRotationToPortrait:(NSTimeInterval)duration{
self.adView.currentContentSizeIdentifier =
ADBannerContentSizeIdentifierPortrait;
BOOL iPad = NO;
#ifdef UI_USER_INTERFACE_IDIOM
iPad = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);
#endif
if (iPad) {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:duration];
proUpgradeDescription.frame = CGRectMake(82,313,604,110);
proUpgradePrice.frame = CGRectMake(313,576,142,28);
closeButton.frame = CGRectMake(348,834,72,37);
purchaseButton.frame = CGRectMake(313,431,142,142);
[UIView commitAnimations];
}
else{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:duration];
proUpgradeDescription.frame = CGRectMake(20,80,280,70);
proUpgradePrice.frame = CGRectMake(88,322,142,28);
closeButton.frame = CGRectMake(123,403,72,37);
purchaseButton.frame = CGRectMake(88,172,142,142);
[UIView commitAnimations]; …Run Code Online (Sandbox Code Playgroud) 在我的应用程序使用AVAudioPlayer播放自己的声音后,我正在寻找一种方法来恢复另一个应用程序播放的音频.现在,如果我正在听音乐并启动我的应用程序,它会暂停音乐,播放我的声音,但不会恢复背景音乐.
这是我正在做的生成声音播放:
myChime = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"chime" ofType:@"mp3"]] error:nil];
myChime.delegate = self;
[myChime play];
// Here I am looking to resume the audio that the system was playing before my application played its sound. I have seen many applications do this such as, GPS apps that speak a voice direction and then resume the music.
Run Code Online (Sandbox Code Playgroud)