我是iPhone开发的新手。我在运行时向UIImageView
添加了很多self.view
个子视图。
我目前的架构是:
UIView
内部有一个UIScrollView
,在UIScrollView
内,还有一个UIView
附加到名为UIView
的{{1}}子类。 SeatingPlan
仅在屏幕上绘制网格。 SeatingPlan
在屏幕上由名为UIImageView
的{{1}}子类绘制。 UIViewController
被添加为子视图。 SeatingPlanViewContoller
保存在UIImageView
中。
.h文件:
UIImageView
.m文件:
NSMutableArray
我想在屏幕上移动@interface SeatingPlanViewController : UIViewController <UIScrollViewDelegate, UIAlertViewDelegate>{
IBOutlet UIScrollView * scrollView;
SeatingPlan * planView;
CGPoint origin;
NSMutableArray * arrayOfImages;
}
。我更喜欢一些示例代码。
我应该在哪里放置触摸处理代码?在视图控制器子类中还是在- (void)viewDidLoad {
[super viewDidLoad];
[self.navigationItem setTitle:@"Seating Planner"];
UIBarButtonItem *mySave = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:self action:@selector(Save)];
self.navigationItem.rightBarButtonItem = mySave;
[mySave release];
segmentController.selectedSegmentIndex = UISegmentedControlNoSegment;
segmentController.momentary = YES;
scrollView.contentSize=CGSizeMake(1280.0,960.0);
[scrollView setBackgroundColor:[UIColor whiteColor]];
scrollView.indicatorStyle = UIScrollViewIndicatorStyleBlack;
[planView addSubview:scrollView];
[self.view addSubview:planView];
}
子类中?