在iOS 8之前,我们将下面的代码与supportedInterfaceOrientations和shouldAutoRotate委托方法结合使用,以强制应用程序方向指向任何特定方向.我使用下面的代码段以编程方式将应用程序旋转到所需的方向.首先,我正在改变状态栏方向.然后只显示并立即关闭模态视图会将视图旋转到所需的方向.
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:YES];
UIViewController *c = [[UIViewController alloc]init];
[self presentViewController:vc animated:NO completion:nil];
[self dismissViewControllerAnimated:NO completion:nil];
Run Code Online (Sandbox Code Playgroud)
但这在iOS 8中失败了.而且,我已经看到堆栈溢出的一些答案,人们建议我们应该始终从iOS 8开始避免这种方法.
更具体地说,我的应用程序是一种通用类型的应用程序.总共有三个控制器.
First View控制器 - 它应该支持iPad中的所有方向,并且只支持iPhone中的纵向(主页按钮).
第二视图控制器 - 它应该只支持所有条件下的横向
第三视图控制器 - 它应该只支持所有条件下的风景
我们使用导航控制器进行页面导航.从第一个视图控制器,在按钮单击操作上,我们在堆栈上推送第二个.因此,当第二个视图控制器到达时,无论设备方向如何,应用程序都应仅锁定横向.
下面是我shouldAutorotate和supportedInterfaceOrientations第二和第三视图控制器中的方法.
-(NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskLandscapeRight;
}
-(BOOL)shouldAutorotate {
return NO;
}
Run Code Online (Sandbox Code Playgroud)
对于这种或任何更好的方法来锁定iOS 8的特定方向的视图控制器是否有任何解决方案.请帮忙!!
我试图在swift中重命名类名,但它给了我错误Can't refector swift code.我想知道重命名将反映在整个项目中的文件的最佳方法
我带了一个带有单独nib文件的ViewController.我的初始根视图控制器在storyBoard中设置.现在问题是当我推送到这个控制器时,没有调用View hireachy方法(ViewDidLoad,ViewWillApper等).
代码(视图已加载但方法未调用)
var viewController = UIViewController(nibName: "OfferDetailViewController", bundle: nil) as OfferDetailViewController
self.navigationController?.pushViewController(viewController, animated: true);
Run Code Online (Sandbox Code Playgroud)
如果我使用故事板它的工作正常,同样的事情.
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
var viewController = mainStoryboard.instantiateViewControllerWithIdentifier("offer") as OfferDetailViewController
self.navigationController?.pushViewController(viewController, animated: true);
Run Code Online (Sandbox Code Playgroud)
问题:使用storyboard View层次结构方法是调用但不是使用单独的nib文件?
我已经看到这提到了网络上的一些地方,但还没有在任何地方找到答案.
我正在使用ALMovieplayercontroller库.一切正常,但当我试图播放Youtube视频时,它给了我错误.
_itemFailedToPlayToEnd:{kind = 1; new = 2; old = 0; }
编辑
- (void)setContentURL:(NSURL *)contentURL {
self.movieSourceType = MPMovieSourceTypeStreaming;
[super setContentURL:contentURL];
[[NSNotificationCenter defaultCenter] postNotificationName:ALMoviePlayerContentURLDidChangeNotification object:nil];
[self play];
}
Run Code Online (Sandbox Code Playgroud)
这是我的代码
ALMoviePlayerControls *movieControls = [[ALMoviePlayerControls alloc] initWithMoviePlayer:self.moviePlayer style:ALMoviePlayerControlsStyleDefault];
//[movieControls setAdjustsFullscreenImage:NO];
[movieControls setBarColor:[UIColor colorWithRed:195/255.0 green:29/255.0 blue:29/255.0 alpha:0.5]];
[movieControls setTimeRemainingDecrements:YES];
//assign controls
[self.moviePlayer setControls:movieControls];
[self.view addSubview:self.moviePlayer.view];
self.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;
//THEN set contentURL
[self.moviePlayer setContentURL:[NSURL URLWithString:@"http://www.youtube.com/watch?v=NaosmAGx8NM"]];
Run Code Online (Sandbox Code Playgroud)
我无法找到解决方案.
请帮忙.
在ios8中委托多次调用UIActionSheet的方法
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
Run Code Online (Sandbox Code Playgroud)
我用IOS 8检查了ipad 2
我在iOS 7中面临MPMoviePlayerController的问题.当我单击前向搜索按钮时,视频停止并且不允许执行任何类似于再次播放全屏和滑块更改的操作.
这是我的代码.删除MPMoviePlayerPlaybackDidFinishNotification的Observer
[[NSNotificationCenter defaultCenter] removeObserver:moviePlayerViewController name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayerViewController.moviePlayer];
Run Code Online (Sandbox Code Playgroud)
并添加新通知MPMoviePlayerPlaybackDidFinishNotification
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(videoFinished:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
Run Code Online (Sandbox Code Playgroud)
这是我处理MPMoviePlayerPlaybackDidFinishNotification的自定义方法
-(void)videoFinished:(NSNotification*)aNotification{
MPMoviePlayerController *moviePlayer = [aNotification object];
NSLog(@"%f",moviePlayer.currentPlaybackTime);
int reason = [[[aNotification userInfo] valueForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey] intValue];
if (reason == MPMovieFinishReasonPlaybackEnded) {
}else if (reason == MPMovieFinishReasonUserExited) {
[self performSelector:@selector(dismiss:) withObject:aNotification afterDelay:0.5];
}else if (reason == MPMovieFinishReasonPlaybackError) {
}
}
Run Code Online (Sandbox Code Playgroud)
我需要在单击时停止这种奇怪的行为并继续播放.
有人知道怎么做吗?谢谢.
我想从字符串中获取数据.我使用以下代码,但它似乎已被弃用.
NSData *data=[[NSData alloc]initWithBase64Encoding:(NSString *)dict];
Run Code Online (Sandbox Code Playgroud)
我得到了数据.但它给我警告'initWithBase64Encoding'已被弃用.那么有没有其他方法可以返回数据?
我正在尝试制作缩略图并保存到文档目录.但问题是,当我试图将缩略图转换为NSData时.它返回零.
这是我的代码,
UIImage *thumbNailimage=[image thumbnailImage:40 transparentBorder:0.2 cornerRadius:0.2 interpolationQuality:1.0];
NSData *thumbNailimageData = UIImagePNGRepresentation(thumbNailimage);// Returns nil
[thumbNailimageData writeToFile:[DOCUMENTPATH stringByAppendingPathComponent:@"1.png"] atomically:NO];
Run Code Online (Sandbox Code Playgroud)
那么我用UIImageJPEGRepresentation尝试过的问题是什么,但它对我不起作用.
谢谢.
我想用这个POST方法调用一个Web服务.我需要发布一个带有URL的字典.我的Web服务参数如下:
ConversationMessage {
authorUserId (string, optional),
subject (string, optional),
hasAttachment (boolean, optional),
conversationId (string, optional),
attachment (DigitalAsset, optional),
content (string, optional),
title (string, optional),
urgency (boolean, optional),
searchable (Map[String,Object], optional)
}
DigitalAsset {
id (string, optional),
assetUrl (string, optional),
assetContent (string, optional),
thumbGenerated (boolean, optional),
fileName (string, optional)
}
Map[String,Object] {
empty (boolean, optional)
}
Run Code Online (Sandbox Code Playgroud)
以下是我的要求:
NSMutableArray *arr=[[NSMutableArray alloc]init];
NSMutableDictionary *dict=[[NSMutableDictionary alloc]init];
[dict setValue:@"test title" forKey:@"title"];
[dict setValue:@"test message" forKey:@"content"];
[dict setValue:@"0" forKey:@"urgency"];
[arr addObject:[NSMutableDictionary dictionaryWithObject:dict forKey:@"ConversationMessage"]];
NSMutableURLRequest …Run Code Online (Sandbox Code Playgroud) 我想在我的应用程序中播放youtube视频.一切正常.但是当我试图观看包含youtube内容的视频时.它失败.
我研究发现有人认为你应该加密和解密签名并将其添加到URL?
我不知道如何decrypt signature在IOS?
http://www.youtube.com/get_video_info?video_id=uuZE_IRwLNI&el=vevo&ps=default&eurl=&gl=US&hl=en
stream
{
"fallback_host" = "tc.v12.cache7.googlevideo.com";
itag = 22;
quality = hd720;
s = "8E6E5D13EB65FB653B173B94CB0BCC3A20853F5EDE8.5E2E87DF33EEDE165FEA90109D3C7D5DADA06B6BB60";
type = "video/mp4; codecs=\"avc1.64001F, mp4a.40.2\"";
url = "http://r7---sn-cvh7zn7r.googlevideo.com/videoplayback?pcm2fr=yes&sver=3&expire=1393773646&itag=22&id=bae644fc84702cd2&upn=SjZd81MudQs&sparams=gcr%2Cid%2Cip%2Cipbits%2Citag%2Cpcm2fr%2Cratebypass%2Csource%2Cupn%2Cexpire&ms=au&gcr=in&mt=1393747698&source=youtube&ratebypass=yes&ipbits=0&fexp=935620%2C919120%2C912523%2C932288%2C914084%2C916626%2C937417%2C937416%2C913434%2C932289%2C936910%2C936913%2C902907&mv=m&key=yt5&ip=103.250.162.79";
}
Run Code Online (Sandbox Code Playgroud)
当我用url它不玩.有什么办法吗?
ios ×10
objective-c ×9
ios7 ×3
iphone ×3
ios8 ×2
swift ×2
autorotate ×1
ipad ×1
json ×1
nsdata ×1
xcode ×1
youtube ×1
youtube-api ×1