我以编程方式创建一个scrollView和一些内部按钮.当我点击任何按钮时必须显示一个弹出窗口.
我的按钮在self.view中的起源就像(100,11),在scrollView(9,11)里面,scrowView在self.view的某个地方.弹出窗口显示在(9,11)但右边一个是(100,11).我尝试使用转换没有成功.
-(IBAction)showPopover:(id)sender{
//... implemented popover above
//Wrong Origin:
NSLog(@"wrong x:%f y:%f",[sender frame].origin.x, [sender frame].origin.y);
//Transform to correct
CGRect frame = [self.view convertRect:[sender frame] toView:nil];
//Shoulf be right, but is not...
NSLog(@"new x:%f y:%f",frame.origin.x, frame.origin.y);
}
Run Code Online (Sandbox Code Playgroud)
有人帮我吗?
我正在使用Compute Engine(GCE)来运行我的套接字服务器和Socket.IO(Node.js)
它只适用于民意调查.当我尝试使用Web客户端时,我收到此错误代码:
WebSocket connection to 'ws://myapp-socket.appspot.com/socket.io/?EIO=3&transport=websocket&sid=Tt4uNFR2fU82zsCIAADo' failed: Unexpected response code: 400
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?是GCE配置问题吗?
我按照教程介绍了如何创建scrollView页面控件:http://www.iosdevnotes.com/2011/03/uiscrollview-paging/
本教程非常好,我实现了很好的代码.我的问题在这里:
我想在我的PageViews之间放一个空格,但是当它改变页面时,它会显示下一页中视图之间的空格.当我更改页面时,滚动必须在空格后停止.
我在这里更改了教程代码:
- (void)viewDidLoad {
[super viewDidLoad];
NSArray *colors = [NSArray arrayWithObjects:[UIColor redColor], [UIColor greenColor], [UIColor blueColor], nil];
#define space 20
for (int i = 0; i < colors.count; i++) {
CGRect frame;
frame.origin.x = (self.scrollView.frame.size.width + space) * i;
frame.origin.y = 0;
frame.size = self.scrollView.frame.
UIView *subview = [[UIView alloc] initWithFrame:frame];
subview.backgroundColor = [colors objectAtIndex:i];
[self.scrollView addSubview:subview];
[subview release];
}
self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * colors.count+ space*(colors.count-1), self.scrollView.frame.size.height);
}
Run Code Online (Sandbox Code Playgroud)