当iPhone中的"A"视图从"B"视图出现时如何获得警报



我有要求,我可以有Alert When吗,

1( 假设"B"视图比"A"视图大
2( "A"视图位于"B"视图之上
3( 当"A"视图使用PanGesture越过"B"视图的边界时,我们应该得到警报。

if (!CGRectContainsRect(B.frame, A.frame))
{
    NSLog(@"ALERT !!!");
}

在平移手势的目标方法中,使用CGRectContainsRect((方法检查A视图的框架是否包含在B视图的框架内。

如果返回"否",则显示您的警报。

 if(!CGRectContainsRect(B.frame, A.frame)){
    //show alert here
}

试试这个。。。

if (!CGRectContainsRect(B.frame, A.frame))
    {
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:@"You have crossed." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
        [alert show];
    }
if (!CGRectContainsRect(B.frame, A.frame))
{
UIAlertView * alert=[[UIAlertView alloc]initWithTitle:@"..." message:@".." delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil, nil];
        [alert show];

}

试试这个。。

最新更新