当前位置:编程学习 > wap >>

大约7,8个view我想在这几个view之间任意的切换,通过touchMove事件。

请问这样的功能该怎么实现?

目前遇到的一个问题是崩溃,在xcode4.2 下。无缘无故的崩溃。

例如切换的代码:

secondViewController = [[SecondViewController alloc] initWithNibName:@"SecondView" bundle:nil];
[self.view addSubview:secondViewController.view];

期望朋友门给点提示或者是例子那就更好了。

--------------------编程问答-------------------- 一起都实例化,然后全部加载上。然后设置他们的显示层次和动画。
才7、8张而已嘛。 --------------------编程问答-------------------- 楼上能否给我个例子? --------------------编程问答--------------------

                v0    = [[UIView   alloc] initWithFrame:CGRectMake(0, 0, 1024,768)];
v1    = [[UIView   alloc] initWithFrame:CGRectMake(0, 0, 1024,768)];
v2    = [[UIView   alloc] initWithFrame:CGRectMake(0, 0, 1024,768)];
v3    = [[UIView   alloc] initWithFrame:CGRectMake(0, 0, 1024,768)];
v4    = [[UIView   alloc] initWithFrame:CGRectMake(0, 0, 1024,768)];
⋯⋯
-(void)setPage:(NSNotification *)pageIndex
{
for(UIView *views in self.view.subviews )
{
[views removeFromSuperview];
}

int i= [[pageIndex object] intValue];

if(i==0){
[self.view addSubview:v0];
}
else if (i == 1) {
[self.view addSubview:v1];
}
else if (i == 2) {
[self.view addSubview:v2];
}
else if (i == 3) {
[self.view addSubview:v3];
}
else if (i == 4) {
[self.view addSubview:v4];
}
else if (i == 5) {
[self.view addSubview:v5];
}
else if (i == 6) {
[self.view addSubview:v6];
}
⋯⋯
}

//动画就自己弄吧  就一个大概的思路。

--------------------编程问答-------------------- UIScrollView拯救世界 --------------------编程问答-------------------- 同意楼上哟。UIScrollView 的 pagingEnabled 然后按顺序addsubView就完事,不用自己处理任何事件 --------------------编程问答--------------------
引用 4 楼 cfyj007 的回复:
UIScrollView拯救世界


--------------------编程问答--------------------
哎~知道什么叫任意切换吗?
UIScrollView切换时内存使用量且不论,显示效果诸位试过吗?
没脑子~ --------------------编程问答-------------------- --------------------编程问答-------------------- ybh37的好像是大神级人物,我在好多帖子里都看到过你,可以认识下吗? --------------------编程问答--------------------
菜菜一个⋯⋯ --------------------编程问答-------------------- 其实,俺以前是泡VB版滴⋯⋯ --------------------编程问答-------------------- 哈哈   谦虚了不是,我才是菜鸟,刚开始学 --------------------编程问答-------------------- --------------------编程问答-------------------- 不太懂问题是什么
补充:移动开发 ,  iPhone
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,