我有一个Information:Gradle tasks [clean, :app:compileDebugSources, :app:compileDebugAndroidTestSources]
:app:clean
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72211Library
:app:prepareComAndroidSupportSupportV42211Library
:app:prepareDebugDependencies
,在按下时会使用public class Signs implements Listener {
@EventHandler
public void onSignChange(SignChangeEvent e) {
if (e.getLine(0).equalsIgnoreCase("[shop]")) {
Block attached = e.getBlock().getRelative(0, -1, 0);
String name = e.getPlayer().getDisplayName();
if (!(attached.getType() == Material.CHEST))
e.getPlayer().sendMessage(ChatColor.RED + "Please place the shop on a chest!");
else {
if (!e.getPlayer().hasPermission("shops.create"))
e.getPlayer().sendMessage(ChatColor.RED + "You don't have permission to create a shop! (shops.create)");
else {
if (!Arrays.asList("open", "closed").contains(e.getLine(1).toLowerCase())) {
e.getPlayer().sendMessage(ChatColor.RED + "You must specify if the shop is open or closed on the second line!");
} else {
boolean closed = true;
if ("open".equalsIgnoreCase(e.getLine(1))) {
closed = false;
}
String lineThree = closed ? "§cClosed" : "§aOpen";
e.setLine(3, lineThree);
e.setLine(0, "§9[Shop]");
e.setLine(1, "§b" + name + "'s");
e.setLine(2, "§bShop");
e.getPlayer().sendMessage(ChatColor.GREEN + "Shop Created!");
e.getPlayer().playSound(e.getPlayer().getLocation(), Sound.LEVEL_UP, 10, 10);
if(getConfig().getStringList(name) == null);
}
}
}
}
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
Player p = e.getPlayer();
Block b = e.getClickedBlock();
Block a = b.getRelative(0, -1, 0);
int ax = a.getX();
int ay = a.getY();
int az = a.getZ();
Material m = b.getType();
if (!(m == Material.SIGN_POST)) {
return;
} else {
Sign sign = (Sign) e.getClickedBlock().getState();
if ((sign.getLine(0).equalsIgnoreCase("§9[Shop]"))) {
if ((sign.getLine(3).equalsIgnoreCase("§aOpen"))) {
p.sendMessage("I opened the shop!");
World world = e.getPlayer().getWorld();
Location chestLocation = new Location(world, ax, ay, az);
}
}
}
}
}
}
打开文本消息对话框。但我有IBAction
语句包含一些语句,我想让MFMessageComposeViewController
"无效"如果其中一个if语句在同一个if
上按下时为真。
所以我的问题很简单,我如何"无效"一个MFMessageComposeViewController
?或者至少不显示对话框?
编辑(代码):
IBAction
谢谢!
答案 0 :(得分:1)
因为MFMessageComposeViewController
也是UIViewController
的一个实例。如果您不再需要它,可以使用dismissViewControllerAnimated
将其关闭。
最好处理MFMailComposeViewControllerDelegate
,这是一个示例代码:
- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error {
NSLog(@"%@", error);
switch (result) {
case MFMailComposeResultCancelled: {
[controller dismissViewControllerAnimated:YES completion:^(){
[SVProgressHUD showInfoWithStatus:@"The email is cancelled"];
}];
break;
}
case MFMailComposeResultFailed: {
[SVProgressHUD showErrorWithStatus:@"Failed to send"];
break;
}
case MFMailComposeResultSaved: {
[controller dismissViewControllerAnimated:YES completion:^(){
[SVProgressHUD showErrorWithStatus:@"The draft is saved"];
}];
break;
}
case MFMailComposeResultSent: {
[controller dismissViewControllerAnimated:YES completion:^(){
[SVProgressHUD showSuccessWithStatus:@"Sent successfully"];
}];
break;
}
default:
break;
}
}