成功安装后 为什么MailboxPickerController的左边没有BarButtonItem
还是老样子
代码:
#import "iOSREMailMarker.h"
%hook MailboxPickerController
%new
- (void)showAlert
{
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Whitelist" message:@"Please input an email address" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
UITextField *textField = alert.textFields.firstObject;
if ([textField.text length] != 0) {
[[NSUserDefaults standardUserDefaults] setObject:textField.text forKey:@"whitelist"];
}
}];
UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"cancel" style:UIAlertActionStyleCancel handler:nil];
[alert addAction:ok];
[alert addAction:cancel];
[alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
textField.placeholder = @"2267536171@qq.com";
textField.text = [[NSUserDefaults standardUserDefaults] objectForKey:@"whitelist"];
}];
[self presentViewController:alert animated:YES completion:nil];
}
- (void)viewWillAppear:(BOOL)arg1
{
self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Whitelist" style:UIBarButtonItemStylePlain target:self action:@selector(showAlert)] autorelease];
%orig;
}
%end
%hook MailboxContentViewController
- (void)megaMallMessageCountChanged:(NSConcreteNotification *)arg1
{
%orig;
NSMutableSet *targetMessage = [NSMutableSet setWithCapacity:600];
NSString *whitelist = [[NSUserDefaults standardUserDefaults] objectForKey:@"whitelist"];
MessageMegaMall *mall = [arg1 object];
NSSet *messages = [mall copyAllMessages];
for (MFLibraryMessage *message in messages) {
MFMessageInfo *messageInfo = [message copyMessageInfo];
for (NSString *sender in [message senders]) {
if (!messageInfo.read && [sender rangeOfString:[NSString stringWithFormat:@"<%@>", whitelist]].location == NSNotFound) {
[targetMessage addObject:message];
}
}
[messageInfo release];
}
[messages release];
[mall markMessagesAsViewed:targetMessage];
}
%end