开发者

UIAlertView not disabling all interaction

Is it possible to use interaction with other windows when a UIAlertView is showing.

Solutions i thought about is an extra UI开发者_StackOverflowWindow falling over the UIAlertView window or an alert with a smaller size.

Has anybody any suggestions/solutions how to achieve this?

Thanks

EDIT:

I have to use a UIAlertView instance. I already found a way to recognize the moment when an UIAlertView is shown.


Just a thought create custom view with your alert text and button and show it as UIAlertView. Clicking on button hide that view. Which will solve your purpose. Below Code you can use for the same. Plz adjust x/y/height/width as per your requirement.

UIView *customAlert = [[UIView alloc] initWithFrame:CGRectMake(100,100,100,100)];
UILabel *lblText = [[UILabel alloc] initWithFrame:CGRectMake(0,0,100,30)];
lblText.text =@"Your alert text";

[customAlert addSubView:lblText];

UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self action:@selector(hideAlertView:) forControlEvents:UIControlEventTouchDown];
[button setTitle:@"OK" forState:UIControlStateNormal];
button.frame = CGRectMake(30.0, 50.0, 50.0, 50.0);
[customAlert addSubview:button];

[self.view addSubView:customAlert];

-(IBAction)hideAlertView:(id)sender
{
     [customAlert removeFromSuperView];
}

EDIT

As UIAlertView is of MODAL behavior you can not touch any other part of your application until it is dismissed.


Swift Solution:

  // Define a view
  var popup:UIView!
  func showAlert() {
    // customise your view
    popup = UIView(frame: CGRect(x: 100, y: 200, width: 200, height: 200))
    popup.backgroundColor = UIColor.redColor()

    // show on screen
    self.view.addSubview(popup)

  }

  func dismissView(){
    // Dismiss the view from here
    popup.removeFromSuperview()
  }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜