2010 Archives

UIViewAnimation with block

| No Comments | No TrackBacks

UIViewAnimationWithBlocks使用block,动画结束后不需要使用回调方法,相比UIViewAnimation 方式要简洁很多


- (void)setSelectedVeg:(id)sender

{    

    [selectedVegetableIcon setAlpha:0.0];

    

    [UIView animateWithDuration:0.4

                     animations: ^{

                         float angle = [self spinnerAngleForVegetable:sender];

                         [vegetableSpinner setTransform:CGAffineTransformMakeRotation(angle)];

                     } 

                     completion:^(BOOL finished) {

                         [selectedVegetableIcon setAlpha:1.0];

                     }];


}

以上代码来自WWDC2010 iPlant PlantCareViem.m


UIViewAnimation style Animation

- (void)setSelectedVeg:(id)sender

{    

    [selectedVegetableIcon setAlpha:0.0];

[UIView beginAnimations:@"setSelectedVeg" context:nil];

float angle = [self spinnerAngleForVegetable:sender];

[vegetableSpinner setTransform:CGAffineTransformMakeRotation(angle)];

[UIView setAnimationDuration:0.4];

[UIView setAnimationDelegate:self];

[UIView setAnimationDidStopSelector:@selector(done)];

[UIView commitAnimations];

}

-(void)done

{

[selectedVegetableIcon setAlpha:1.0];

}

lldb help

| No Comments | No TrackBacks
MacBook-Pro:~ yarshure$ /Users/yarshure/lldb/lldb/build/Debug/lldb 
(lldb) help
The following is a list of built-in, permanent debugger commands:

alias        -- Allows users to define their own debugger command abbreviations.
append       -- Allows the user to append a value to a single debugger setting variable, for settings that are of list types. Type 'settings' to see a list of debugger setting variables
apropos      -- Finds a list of debugger commands related to a particular word/subject.
breakpoint   -- A set of commands for operating on breakpoints.
call         -- Call a function.
delete       -- Lists the kinds of objects you can delete, and shows syntax for deleting them.
disassemble  -- Disassemble bytes in the current function or anywhere in the inferior program.
expression   -- Evaluate a C expression in the current program context, using variables currently in scope.
file         -- Sets the file to be used as the main executable by the debugger.
frame        -- A set of commands for operating on the current thread's frames.
help         -- Shows a list of all debugger commands, or give details about specific commands.
image        -- Access information for one or more executable images.
info         -- Lists the kinds of objects for which you can get information, and shows the syntax for doing so.
log          -- A set of commands for operating on logs.
memory       -- A set of commands for operating on a memory.
process      -- A set of commands for operating on a process.
quit         -- Quits out of the LLDB debugger.
regexp-break -- Smart breakpoint command (using regular expressions).
register     -- Access thread registers.
script       -- Passes an expression to the script interpreter for evaluation and returns the results. Drops user into the interactive interpreter if no expressions are given.
select       -- Lists the kinds of objects you can select, and shows syntax for selecting them.
set          -- Allows the user to set or change the value of a single debugger setting variable.
settings     -- Lists the debugger settings variables available to the user to 'set' or 'show'.
show         -- Allows the user to see a single debugger setting variable and its value, or lists them all.
source       -- Reads in debugger commands from the file <filename> and executes them.
source-file  -- Display source files from the current executable's debug info.
target       -- A set of commands for operating on debugger targets.
thread       -- A set of commands for operating on one or more thread within a running process.
unalias      -- Allows the user to remove/delete a user-defined command abbreviation.
variable     -- Access program arguments, locals, static and global variables.

The following is a list of your current command abbreviations (see 'alias' for more info):

bt       -- ('thread backtrace')  Shows the stack for one or more threads.
c        -- ('process continue')  Continues execution all threads in the current process.
continue -- ('process continue')  Continues execution all threads in the current process.
exit     -- ('quit')  Quits out of the LLDB debugger.
expr     -- ('expression')  Evaluate a C expression in the current program context, using variables currently in scope.
finish   -- ('thread step-out')  Source level single step out in specified thread (current thread, if none specified).
l        -- ('source-file')  Display source files from the current executable's debug info.
list     -- ('source-file')  Display source files from the current executable's debug info.
n        -- ('thread step-over')  Source level single step over in specified thread (current thread, if none specified).
next     -- ('thread step-over')  Source level single step over in specified thread (current thread, if none specified).
q        -- ('quit')  Quits out of the LLDB debugger.
r        -- ('process launch')  Launches the executable in the debugger.
run      -- ('process launch')  Launches the executable in the debugger.
s        -- ('thread step-in')  Source level single step in in specified thread (current thread, if none specified).
si       -- ('thread step-inst')  Single step one instruction in specified thread (current thread, if none specified).
step     -- ('thread step-in')  Source level single step in in specified thread (current thread, if none specified).
x        -- ('memory read')  Read memory from the process being debugged.

For more information on any particular command, try 'help <command-name>'.
Enhanced by Zemanta

2010-06-15 09:35:14.408 JoyPlayer[494:207] *** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit/UIKit-984.38/UITableView.m:772

2010-06-15 09:35:14.408 JoyPlayer[494:207] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of sections.  The number of sections contained in the table view after the update (2) must be equal to the number of sections contained in the table view before the update (1), plus or minus the number of sections inserted or deleted (0 inserted, 0 deleted).'

2010-06-15 09:35:14.409 JoyPlayer[494:207] Stack: (

    36209755,

    2528503049,

    36293691,

    2776852,

    5075846,

    5020217,

    43132,

    387640,

    2454948,

    2454803,

    32134584,

    32132632,

    32135830,

    31795157,

    35993825,

    35990600,

    41654157,

    41654354,

    4763651,

    10756,

    10610

)

InAppSMS

| No Comments | No TrackBacks

- (IBAction)sendSMS {

BOOL canSendSMS = [MFMessageComposeViewController canSendText];

NSLog(@"can send SMS [%d]", canSendSMS);

if (canSendSMS) {

MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];

picker.messageComposeDelegate = self;

picker.navigationBar.tintColor = [UIColor blackColor];

picker.body = @"test";

picker.recipients = [NSArray arrayWithObject:@"186-0123-0123"];

[self presentModalViewController:picker animated:YES];

[picker release];

}

}


- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result {

// Notifies users about errors associated with the interface

switch (result) {

case MessageComposeResultCancelled:

if (DEBUG) NSLog(@"Result: canceled");

break;

case MessageComposeResultSent:

if (DEBUG) NSLog(@"Result: Sent");

break;

case MessageComposeResultFailed:

if (DEBUG) NSLog(@"Result: Failed");

break;

default:

break;

}

[self dismissModalViewControllerAnimated:YES];

}

KongXiangBo-iPad:~ root# hostinfo

| No Comments | No TrackBacks
KongXiangBo-iPad:~ root# hostinfo
Mach kernel version:
Darwin Kernel Version 10.3.1: Mon Mar 15 23:15:33 PDT 2010; root:xnu-1504.2.27~18/RELEASE_ARM_S5L8930X
Kernel configured for a single processor only.
1 processor is physically available.
1 processor is logically available.
Processor type: armv7 (arm v7)
Processor active: 0
Primary memory available: 247.00 megabytes
Default processor set: 27 tasks, 184 threads, 1 processors
Load average: 0.06, Mach factor: 0.93

LOGO_320×44.png 图片显示在背景上,

@implementation UINavigationBar (UINavigationBarCategory)

- (void)drawRect:(CGRect)rect {

//加入旋转坐标系代码

    // Drawing code

UIImage *navBarImage = [UIImage imageNamed:@"LOGO_320×44.png"];

CGContextRef context = UIGraphicsGetCurrentContext();

CGContextTranslateCTM(context, 0.0, self.frame.size.height);

CGContextScaleCTM(context, 1.0, -1.0);

CGPoint center=self.center;


CGImageRef cgImage= CGImageCreateWithImageInRect(navBarImage.CGImage, CGRectMake(0, 0, 1, 44));

CGContextDrawImage(context, CGRectMake(center.x-160-80, 0, 80, self.frame.size.height), cgImage);

CGContextDrawImage(context, CGRectMake(center.x-160, 0, 320, self.frame.size.height), navBarImage.CGImage);

CGContextDrawImage(context, CGRectMake(center.x+160, 0, 80, self.frame.size.height), cgImage);


}

@end

old code

CGContextDrawImage(context, CGRectMake(0, 0, self.frame.size.width, self.frame.size.height), navBarImage.CGImage);

hack 过logo 不再拉伸
nav_bar.png


sel_registerName 使用

| No Comments | No TrackBacks
Q: 已知一个字符串,如何让objctive c 实例执行字符串代笔的方法?
A: 使用sel_registerName 注册成SEL,然后使用respondsToSelector判断是否可以执行,如果可以执行,那么使用performSelector 来执行

- (void)configureView:(NSString *)performaction {


if ([performaction length] >0) {

SEL sel=sel_registerName([performaction UTF8String]);

if ([self respondsToSelector:sel]) {

[self performSelector:sel];

}

}

}