PhoneGap 2.9.0
简单谈谈eclipse下搭建PhoneGap环境来开发Android程序
Hello World! with PhoneGap, Android and Eclipse
【APP開發技術】原生開發以外另一種思維:PhoneGap X iOS 起手式
./create ~/Desktop/projects/HelloWorld/ com.demo.HelloWorld HelloWorld
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"CellIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// Configure the cell...
cell = [self getCellContentView: CellIdentifier];
TTTAttributedLabel *masterLabel = ((TTTAttributedLabel *)[cell viewWithTag: 2]);
NSString* text = @"這是我的名片,請多指教。";
NSMutableAttributedString * tttstring = [[NSMutableAttributedString alloc] initWithString:text];
//字型與字體大小
NSRange textRange = [text rangeOfString:text];
UIFont *textSystemFont = [UIFont fontWithName: @"HeiTi TC" size: 18] ;
CTFontRef italicFont = CTFontCreateWithName((__bridge CFStringRef)textSystemFont.fontName, textSystemFont.pointSize, NULL);
if(italicFont){
[tttstring addAttribute:(NSString *)kCTFontAttributeName value:(__bridge id)italicFont range:textRange];
}
CFRelease(italicFont);
//紅字
NSRange redRange = [text rangeOfString:@"名片"];
[tttstring addAttribute:(NSString*)kCTForegroundColorAttributeName value:(id)[[UIColor redColor] CGColor] range:redRange];
//底線
NSRange underlinRange = [text rangeOfString:@"請多指教"];
[tttstring addAttribute:(NSString *)kCTUnderlineStyleAttributeName value:[NSNumber numberWithBool:YES] range:underlinRange];
//組體
UIFont *boldSystemFont = [UIFont boldSystemFontOfSize: 18] ;
CTFontRef boldFont = CTFontCreateWithName((__bridge CFStringRef)boldSystemFont.fontName, boldSystemFont.pointSize, NULL);
if(boldFont){
[tttstring addAttribute:(NSString *)kCTFontAttributeName value:(__bridge id)boldFont range:underlinRange];
}
CFRelease(boldFont);
masterLabel.frame = MASTER_RECT;
masterLabel.numberOfLines = 1;
[masterLabel setBackgroundColor:[UIColor clearColor]];//clearTextBackgroundColor!
[masterLabel setText:tttstring];
return cell;
}
#pragma mark -
#pragma mark custom cell view
- (UITableViewCell *) getCellContentView:(NSString *)cellIdentifier
{
CGRect cellFrame = (self.mainTableView.style == UITableViewStylePlain)? CGRectMake(0, 0, 320, 58) : CGRectMake(0, 0, 300, 58);
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier: cellIdentifier];
cell.frame = cellFrame;
TTTAttributedLabel *master = [[TTTAttributedLabel alloc] initWithFrame: MASTER_RECT];
master.tag = 2;
master.numberOfLines = 1;
master.lineBreakMode = UILineBreakModeWordWrap;
[master setFont: [UIFont fontWithName: @"HeiTi TC" size: 18]];
[cell.contentView addSubview: master];
return cell;
}
@interface ViewController : UIViewController @end @interface UINavigationBar (BackgoundImage) @end在新类别的实现中,覆盖原有类的方法 - (void)drawRect:(CGRect)rect :
@interface ViewController ()
@end
@implementation UINavigationBar (BackgoundImage)
- (void)layoutSubviews {
CGRect barFrame = self.frame;
barFrame.size.height = 100.0; //新的高度
self.frame = barFrame;
}
//其实只需要覆盖该方法就行,把self.frame.size.height改成100.0就OK
- (void)drawRect:(CGRect)rect {
UIImage *image = [UIImage imageNamed:@"unit_nb.png"];
[image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}
@end
storyboard調整要放在viewDidAppear上 放在viewWillDidAppear上 TabBar切換會有問題
//for prepareForSegue
#import "NextPage.h"
#pragma mark - Segues
-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Make sure we're referring to the correct segue
if ([[segue identifier] isEqualToString:@"PushNextPage"]) {
// Get reference to the destination view controller
WordBankVocabulary *vc = [segue destinationViewController];
// get the selected index
NSLog(@"get the selected index");
NSInteger selectedIndex = [[self.tableView indexPathForSelectedRow] row];
// Pass the name and index of our film
[vc setSelectedIndex:selectedIndex];
NSLog(@"prepareForSegue: %d",selectedIndex+1);
}
NSLog(@"prepareForSegue: run");
}
NextPage@interface WordBankVocabulary : UITableViewController
{
NSInteger selectedIndex;
}
@property (nonatomic) NSInteger selectedIndex;
@synthesize selectedIndex;
#pragma mark - Table view data source
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"CellIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// Configure the cell...
NSString *textSelectedIndex = [[NSString alloc] initWithFormat: @"%d",selectedIndex];
cell.textLabel.text = textSelectedIndex;
return cell;
}