小编f0r*_*0rz的帖子

取消UILocalNotification

我的UILocalNotification有问题.

我正在使用我的方法安排通知.

- (void) sendNewNoteLocalReminder:(NSDate *)date  alrt:(NSString *)title
{
    // some code ...
    UILocalNotification *localNotif = [[UILocalNotification alloc] init]; 

    if (localNotif == nil)  
        return;

    localNotif.fireDate = itemDate; 
    localNotif.timeZone = [NSTimeZone defaultTimeZone];
    localNotif.alertAction = NSLocalizedString(@"View Details", nil); 
    localNotif.alertBody = title;
    localNotif.soundName = UILocalNotificationDefaultSoundName; 
    localNotif.applicationIconBadgeNumber = 0;

    NSDictionary *infoDict = [NSDictionary dictionaryWithObject:stringID forKey:@"id"]; 
    localNotif.userInfo = infoDict; 

    [[UIApplication sharedApplication] scheduleLocalNotification:localNotif]; 
    [localNotif release];
}
Run Code Online (Sandbox Code Playgroud)

它工作正常,我正确收到通知.问题是我应该取消通知.我正在使用这种方法.

- (void) deleteNewNoteLocalReminder:(NSString*) reminderID noteIDe:(NSInteger)noteIDE
{
    [[UIApplication sharedApplication] cancelLocalNotification:(UILocalNotification *)notification ????  
}
Run Code Online (Sandbox Code Playgroud)

我不知道该怎么做,但我的问题是:

我如何知道应删除哪个UILocalNotification对象?
有没有办法列出所有通知?

我唯一拥有的是我应删除的提醒ID.
我正在考虑将UILocalNotification对象保存在我的"Note"对象中并以此方式获取,当我保存到我的SQLite数据库时序列化对象等等......是否有更聪明的方法?

iphone notifications cocoa-touch ios4

48
推荐指数
5
解决办法
4万
查看次数

具有自定义XML布局的按钮

是否可以创建具有自定义xml布局的按钮?

我有这个布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:padding="1dp"
  android:background="#7e7e7e">

 <RelativeLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:padding="10dp"
   android:background="#f9f9f9">

 <TextView
  android:id="@+id/TextView01" 
  android:layout_width="wrap_content" 
  android:layout_height="wrap_content"
  android:layout_alignParentLeft="true"
  android:text="ButtText"
  android:textColor="#000000">
 </TextView>

 <ImageView 
  android:id="@+id/ImageView01" 
  android:layout_width="wrap_content" 
  android:layout_height="wrap_content" 
  android:background="@drawable/arrow"
  android:layout_alignParentRight="true">
 </ImageView>

 </RelativeLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

现在我想在一个按钮上使用它.谁知道我怎么做到这一点?
我在想是否有Button.java文件扩展了Button.然后是setView(R.layout.mylayout.xml); ......但这很容易,而且显然不起作用

关心马丁

xml android button

8
推荐指数
2
解决办法
1万
查看次数

确认UITextview自动完成

这似乎不可能,但也许其他人也有同样的问题.

我是否可以通过编程方式接受自动填充,或以某种方式获取弹出的建议单词?我的问题是我正在捕获返回/退格键击,然后将焦点移动到另一个textview.当输入/退格时,textview将忽略自动建议的单词.似乎只能通过命中空格/点(并返回新行)来接受自动完成.使用此代码:

 - (BOOL) textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range
                                replacementText:(NSString *)text {
    NSRange textViewRange = [textView selectedRange];

    // Handle newrow and backspace.  
    if(([text length] == 0) && (textViewRange.location== 0) && textViewRange.length==0){
        // BACKSPACE KEYSTROKE
        [delegate doSomethingWhenBackspace];
        return NO;      
    }else if ([text isEqualToString:@"\n"]){    
        // RETURN KEYSTROKE
        [delegate doSomethingWhenReturn];       
        return NO;      
    }

    return YES;
}
Run Code Online (Sandbox Code Playgroud)

我尝试以编程方式在返回键时添加"space",但也忽略了自动完成的单词.

else if ([text isEqualToString:@"\n"]){ 
                // Tryin to accept autocomplete with no result. 
                textview.text = [textview.text stringByAppendingString:@" "];
            // RETURN KEYSTROKE
            [delegate doSomethingWhenReturn];       
            return NO;      
        }
Run Code Online (Sandbox Code Playgroud)

有什么建议?

iphone uitextview uitextviewdelegate ios

8
推荐指数
1
解决办法
1921
查看次数

使用动画更改UITextView文本颜色

只是一个简单的问题.是否可以用动画更改UITextView的文本颜色?

[UITextView beginAnimations:nil context:NULL]; 
[UITextView setAnimationDuration:2.0]; 
     textView.textColor = [UIColor grayColor];  
[UITextView commitAnimations];   
Run Code Online (Sandbox Code Playgroud)

干杯!
- 马丁

iphone animation uitextview

5
推荐指数
3
解决办法
4838
查看次数

进入Editmode时的UITableView动画

也许我只是愚蠢但我不明白为什么这不起作用.当我在UITableView中进入编辑模式时,我想实现一点动画.

 [super setEditing:NO animated:YES];   
 [myTable setEditing:NO animated:YES];
 [myTable reloadData];
 [self.navigationItem.leftBarButtonItem setTitle:@"Edit"];
 [self.navigationItem.leftBarButtonItem setStyle:UIBarButtonItemStylePlain];
Run Code Online (Sandbox Code Playgroud)

不应该动画:是的,假设动画这个编辑模式的输入?

问候.
- f0rz

iphone cocoa-touch uitableview uianimation

3
推荐指数
1
解决办法
3270
查看次数