Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 如何防止TTPostController';在出现错误时,您的模态视图不会被取消吗?_Iphone_Objective C_Three20 - Fatal编程技术网

Iphone 如何防止TTPostController';在出现错误时,您的模态视图不会被取消吗?

Iphone 如何防止TTPostController';在出现错误时,您的模态视图不会被取消吗?,iphone,objective-c,three20,Iphone,Objective C,Three20,对于使用TTPostController的用户,在发送请求之前和之后如何处理用户错误?i、 例如,如果用户试图发布空白评论,我希望能够提醒他们并保持视图处于活动状态,以便他们能够修复它 但我遇到的问题是,在出现问题后,让模态视图保持打开状态。我可以提醒用户,但一旦他们单击OK,模式就会被取消。我以为我可以使用TTPostControllerDelegate:willPostText委托来完成这项任务,但这似乎不起作用,或者我不太清楚它的设计原理 我在做什么: /** * The user ha

对于使用TTPostController的用户,在发送请求之前和之后如何处理用户错误?i、 例如,如果用户试图发布空白评论,我希望能够提醒他们并保持视图处于活动状态,以便他们能够修复它

但我遇到的问题是,在出现问题后,让模态视图保持打开状态。我可以提醒用户,但一旦他们单击OK,模式就会被取消。我以为我可以使用TTPostControllerDelegate:willPostText委托来完成这项任务,但这似乎不起作用,或者我不太清楚它的设计原理

我在做什么:

/**
 * The user has posted text and an animation is about to show the text return to its origin.
 *
 * @return whether to dismiss the controller or wait for the user to call dismiss.
 */
- (BOOL)postController:(TTPostController*)postController willPostText:(NSString*)text {
    if ([text length] == 0) {
        UIAlertView * alert = [[UIAlertView alloc] initWithTitle:nil 
                                                         message:@"Your message is blank" 
                                                        delegate:self 
                                               cancelButtonTitle:@"OK" 
                                               otherButtonTitles:nil ];
        [alert show];
        [alert release];    

        return false;
    }        
    return true;
}
如果我尝试发布一条空白评论,我会收到一条通知,但一旦我按下OK,模态视图get就会被取消

有什么我遗漏了或没有正确理解的吗


编辑:我还应该注意,我尝试使用alertView的didDismissWithButtonIndex:方法尝试停止卸载视图,但没有成功。

前几天我遇到了这个问题。如果将nil而不是self作为委托传递到:

UIAlertView initWithTitle:message:delegate:cancelButtonTitle:otherButtonTitles 
当用户触摸“确定”时,TTPOST控制器不再关闭


谢谢,亲爱的!一旦我发现了这一点,我就应该发布一个跟进,这是在我发布问题后不久。将此标记为已接受的答案。
- (BOOL)postController:(TTPostController*)postController willPostText:(NSString*)text {
    if ([text length] == 0) {
        UIAlertView * alert = [[UIAlertView alloc] initWithTitle:nil 
                                                         message:@"Your message is blank" 
                                                        delegate:nil 
                                               cancelButtonTitle:@"OK" 
                                               otherButtonTitles:nil ];
        [alert show];
        [alert release];    

        return false;
    }        
    return true;
}