簡體   English   中英

觸摸uiview時如何打開新視圖?

[英]How to open a new view when touching on a uiview?

我有一個UIScrollView其中UIView添加為子視圖。 現在,當我觸摸視圖時如何打開一個新視圖?

我希望出現新視圖。在此之前,我在視圖上有按鈕...因此按鈕具有方法“ addtarget perform selector” ...從此我正在加載新視圖

這是我的觀點

替代文字

例如,嘗試以下代碼(將其添加到視圖中):

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 
{
    UITouch *touch = [touches anyObject];
    NSUInteger tapCount = [touch tapCount];
    CGPoint location = [touch locationInView:self.view];

    switch (tapCount)
    {
         case 1:
         {
              UIView *view = [[UIView alloc] initWithFrame: CGRectMake(0.0f, 0.0f, 320.0f, 480.0f)];
              view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
              view.backgroundColor = [UIColor whiteColor];

              [self.view addSubview:view];
              [view release];
         }
         break;
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM