我UIPageControl第一次尝试使用 a ,但似乎无法让它在UIControlEventValueChanged. 我在这里错过了什么吗?我什至尝试了故事板实现,但结果同样糟糕。我也尝试过UIControlEventTouchUpInside其他操作。没有人调用changePage:下面的函数。
在.h中:
@property (nonatomic, retain) UIPageControl *introPageControl;
-(IBAction)changePage:(id)sender;
Run Code Online (Sandbox Code Playgroud)
在他们之中:
@synthesize introPageControl;
- (void)viewDidLoad {
[super viewDidLoad];
self.introPageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(0,208,self.view.frame.size.width,36)];
self.introPageControl.numberOfPages = 4;
self.introPageControl.currentPage = 0;
[self.introPageControl addTarget:self action:@selector(changePage:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:self.introPageControl];
}
-(IBAction)changePage:(id)sender {
// NEVER GETS CALLED :(
}
Run Code Online (Sandbox Code Playgroud) 我需要在iOS应用程序中从它的URL获取CDN的IP地址.从长堆栈搜索,我已经确定了使用以下方法执行此操作的方法:
struct hostent *host_entry = gethostbyname("stackoverflow.com");
char *buff;
buff = inet_ntoa(*((struct in_addr *)host_entry->h_addr_list[0]));
// buff is now equal to the IP of the stackoverflow.com server
Run Code Online (Sandbox Code Playgroud)
但是,在使用此代码段时,我的应用程序无法编译并显示此警告:"取消引用指向不完整类型的指针"
我不知道结构,我不知道如何解决这个问题.有什么建议?
我也尝试过:
#include <ifaddrs.h>
#include <arpa/inet.h>
Run Code Online (Sandbox Code Playgroud)
但结果是同样的警告.
我无法将异步NSURLRequests发送到Ruby服务器.当我使用以下内容时,永远不会建立连接:
self.data = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:@"http://domain.com/app/create_account.json"]];
[request setHTTPMethod:@"POST"];
[request addValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request addValue:@"application/json" forHTTPHeaderField:@"Accept"];
[request addValue:@"form-data" forHTTPHeaderField:@"Content-Disposition"];
[request setHTTPBody:[data dataUsingEncoding:NSUTF8StringEncoding]];
[[NSURLConnection alloc] initWithRequest:request delegate:self];
Run Code Online (Sandbox Code Playgroud)
但是,当我用最后一行交换:
NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
Run Code Online (Sandbox Code Playgroud)
一切都很好.但我确实需要异步进行此连接...
编辑工作实例
NSURL *url = [NSURL URLWithString:@"http://domain.com/app/create_account.json"];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setPostValue:data forKey:@"data"];
[request setDelegate:self];
[request startAsynchronous];
Run Code Online (Sandbox Code Playgroud)
在这种情况下,似乎RESTful服务需要他们自己的第三方框架.
我正在使用iOS 6中包含的mediaplayer框架尝试在应用程序中播放电影.我导入然后:
-(IBAction)playMovie:(id)sender
{
NSString *filepath = [[NSBundle mainBundle] pathForResource:@"buyTutorial" ofType:@"mov"];
NSURL *fileURL = [NSURL fileURLWithPath:filepath];
MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
[self.view addSubview:moviePlayerController.view];
moviePlayerController.fullscreen = YES;
[moviePlayerController play];
}
Run Code Online (Sandbox Code Playgroud)
调用此函数时,视图将转到空白屏幕并进行无限加载.我已尝试过此实现的许多其他版本,结果各不相同,都失败了.登录的具体情况是:
2012-11-05 21:19:27.900 [MPAVController] Autoplay: Disabling autoplay for pause
2012-11-05 21:19:27.902 [MPAVController] Autoplay: Disabling autoplay
2012-11-05 21:19:27.977 [MPAVController] Autoplay: Disabling autoplay for pause
2012-11-05 21:19:27.978 [MPAVController] Autoplay: Disabling autoplay
2012-11-05 21:19:27.984 [MPAVController] Autoplay: Skipping autoplay, disabled (for current item: 1, on player: 0)
2012-11-05 21:19:28.156 [MPAVController] Autoplay: Enabling autoplay
Run Code Online (Sandbox Code Playgroud)
有关于原因的想法?这是我第一次尝试播放视频,现在已经成为一场噩梦.
objective-c ×4
ios ×2
asynchronous ×1
hostname ×1
ip ×1
iphone ×1
loading ×1
media-player ×1
restkit ×1
ruby ×1
uiscrollview ×1
xcode ×1