当前位置: 编程技术>移动开发
本页文章导读:
▪app开机启动遇到的有关问题 app开机启动遇到的问题
今天在做开机启动app的时候遇到一个问题, 就是当你的app安装到sdcard里时, 使用BroadcastReceiver来实现开机启动app是不行的。 因为ACTION_BOOT_COMPLETED broadcast是在mount sdc.........
▪ ls -l 下令详细解释 ls -l 命令详细解释
fenghuo@bluesky:~/folder$ ls -l
total 244 //该目录的总容量(kb)
-rwxrwxrwx 1 root root 245272 2011-09-20 15:10 com.google.android.maps.jar
-rwxrwxrwx 1 root root 816 2011-09-20 15:08 com.google.android..........
▪ UISearchBar and UITableView搜寻例子 UISearchBar and UITableView搜索例子
UISearchBar and UITableView是我们很常用的组合,在uisearchbar搜索之后,在uitableview显示你搜索后的数据,先看最终效果图如下:拖入UISearchBar and UITableView两个控件.........
[1]app开机启动遇到的有关问题
来源: 互联网 发布时间: 2014-02-18
app开机启动遇到的问题
今天在做开机启动app的时候遇到一个问题, 就是当你的app安装到sdcard里时, 使用BroadcastReceiver来实现开机启动app是不行的。 因为ACTION_BOOT_COMPLETED broadcast是在mount sdcard之前的, 所以你的app那时候还没有ready。 所以只有把你的app安装到phone里面。 我看了task killer也是这样的。
开机启动:http://l12052124.iteye.com/blog/893106
原因:http://stackoverflow.com/questions/5741987/android-how-to-start-an-application-on-the-sdcard-after-boot
今天在做开机启动app的时候遇到一个问题, 就是当你的app安装到sdcard里时, 使用BroadcastReceiver来实现开机启动app是不行的。 因为ACTION_BOOT_COMPLETED broadcast是在mount sdcard之前的, 所以你的app那时候还没有ready。 所以只有把你的app安装到phone里面。 我看了task killer也是这样的。
开机启动:http://l12052124.iteye.com/blog/893106
原因:http://stackoverflow.com/questions/5741987/android-how-to-start-an-application-on-the-sdcard-after-boot
[2] ls -l 下令详细解释
来源: 互联网 发布时间: 2014-02-18
ls -l 命令详细解释
fenghuo@bluesky:~/folder$ ls -l
total 244 //该目录的总容量(kb)
-rwxrwxrwx 1 root root 245272 2011-09-20 15:10 com.google.android.maps.jar
-rwxrwxrwx 1 root root 816 2011-09-20 15:08 com.google.android.maps.xml
《-代表文件,d代表目录,l代表链接,一个快捷键,b设备文件block》
《r表是读 (Read),w表示写 (Write),x表示执行 (eXecute) 其中前三个表示文件属主的权限,中间三个表示组用户权限,最后三个表示其他用户权限》
《1 代表子目录数目,默认有两个为2;如果不是目录,则代表文件的名字(链接)的数目》
《第一个root,文件拥有者;linux属于多用户操作系统,每个文件都有自己的拥有者,root用户具有改动任何文件属性的权利》
《第二个用户是文件拥有者所在组,组的成员和other用户的权限可以设置不同》
《第5个字段,文件大小》 如果是文件夹,指的是文件夹本身的大小,而不是文件夹内部所有文件的总的大小
修改权限sudo chomd 777 文件名
sudo chmod a+x 文件名
修改所有者和组
sudo chown -R 所有者:组 文件 名
[3] UISearchBar and UITableView搜寻例子
来源: 互联网 发布时间: 2014-02-18
UISearchBar and UITableView搜索例子
UISearchBar and UITableView是我们很常用的组合,在uisearchbar搜索之后,在uitableview显示你搜索后的数据,先看最终效果图如下:
拖入UISearchBar and UITableView两个控件,SearchViewController.h代码如下:
//
// SearchViewController.h
//
#import <UIKit/UIKit.h>
@interface SearchViewController : UIViewController
<UISearchBarDelegate, UITableViewDataSource> {
NSMutableArray *tableData;
UIView *disableViewOverlay;
UITableView *theTableView;
UISearchBar *theSearchBar;
}
@property(retain) NSMutableArray *tableData;
@property(retain) UIView *disableViewOverlay;
@property (nonatomic, retain) IBOutlet UITableView *theTableView;
@property (nonatomic, retain) IBOutlet UISearchBar *theSearchBar;
- (void)searchBar:(UISearchBar *)searchBar activate:(BOOL) active;
@end
SearchViewController.m 如下:
//
// SearchViewController.m
//
#import "SearchViewController.h"
@implementation SearchViewController
@synthesize tableData;
@synthesize disableViewOverlay;
@synthesize theSearchBar;
@synthesize theTableView;
// Initialize tableData and disabledViewOverlay
- (void)viewDidLoad {
[super viewDidLoad];
self.tableData =[[NSMutableArray alloc]init];
self.disableViewOverlay = [[UIView alloc]
initWithFrame:CGRectMake(0.0f,44.0f,320.0f,416.0f)];
self.disableViewOverlay.backgroundColor=[UIColor blackColor];
self.disableViewOverlay.alpha = 0;
}
// Since this view is only for searching give the UISearchBar
// focus right away
- (void)viewDidAppear:(BOOL)animated {
[self.theSearchBar becomeFirstResponder];
[super viewDidAppear:animated];
}
#pragma mark -
#pragma mark UISearchBarDelegate Methods
- (void)searchBar:(UISearchBar *)searchBar
textDidChange:(NSString *)searchText {
// We don't want to do anything until the user clicks
// the 'Search' button.
// If you wanted to display results as the user types
// you would do that here.
}
- (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar {
// searchBarTextDidBeginEditing is called whenever
// focus is given to the UISearchBar
// call our activate method so that we can do some
// additional things when the UISearchBar shows.
[self searchBar:searchBar activate:YES];
}
- (void)searchBarTextDidEndEditing:(UISearchBar *)searchBar {
// searchBarTextDidEndEditing is fired whenever the
// UISearchBar loses focus
// We don't need to do anything here.
}
- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar {
// Clear the search text
// Deactivate the UISearchBar
searchBar.text=@"";
[self searchBar:searchBar activate:NO];
}
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {
// Do the search and show the results in tableview
// Deactivate the UISearchBar
// You'll probably want to do this on another thread
// SomeService is just a dummy class representing some
// api that you are using to do the search
NSArray *results = [SomeService doSearch:searchBar.text];
[self searchBar:searchBar activate:NO];
[self.tableData removeAllObjects];
[self.tableData addObjectsFromArray:results];
[self.theTableView reloadData];
}
// We call this when we want to activate/deactivate the UISearchBar
// Depending on active (YES/NO) we disable/enable selection and
// scrolling on the UITableView
// Show/Hide the UISearchBar Cancel button
// Fade the screen In/Out with the disableViewOverlay and
// simple Animations
- (void)searchBar:(UISearchBar *)searchBar activate:(BOOL) active{
self.theTableView.allowsSelection = !active;
self.theTableView.scrollEnabled = !active;
if (!active) {
[disableViewOverlay removeFromSuperview];
[searchBar resignFirstResponder];
} else {
self.disableViewOverlay.alpha = 0;
[self.view addSubview:self.disableViewOverlay];
[UIView beginAnimations:@"FadeIn" context:nil];
[UIView setAnimationDuration:0.5];
self.disableViewOverlay.alpha = 0.6;
[UIView commitAnimations];
// probably not needed if you have a details view since you
// will go there on selection
NSIndexPath *selected = [self.theTableView
indexPathForSelectedRow];
if (selected) {
[self.theTableView deselectRowAtIndexPath:selected
animated:NO];
}
}
[searchBar setShowsCancelButton:active animated:YES];
}
#pragma mark -
#pragma mark UITableViewDataSource Methods
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section {
return [tableData count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyIdentifier = @"SearchResult";
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:MyIdentifier] autorelease];
}
id *data = [self.tableData objectAtIndex:indexPath.row];
cell.textLabel.text = data.name;
return cell;
}
#pragma mark -
#pragma mark Memory Management Methods
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[theTableView release], theTableView = nil;
[theSearchBar release], theSearchBar = nil;
[tableData dealloc];
[disableViewOverlay dealloc];
[super dealloc];
}
@end
UISearchBar and UITableView是我们很常用的组合,在uisearchbar搜索之后,在uitableview显示你搜索后的数据,先看最终效果图如下:
拖入UISearchBar and UITableView两个控件,SearchViewController.h代码如下:
//
// SearchViewController.h
//
#import <UIKit/UIKit.h>
@interface SearchViewController : UIViewController
<UISearchBarDelegate, UITableViewDataSource> {
NSMutableArray *tableData;
UIView *disableViewOverlay;
UITableView *theTableView;
UISearchBar *theSearchBar;
}
@property(retain) NSMutableArray *tableData;
@property(retain) UIView *disableViewOverlay;
@property (nonatomic, retain) IBOutlet UITableView *theTableView;
@property (nonatomic, retain) IBOutlet UISearchBar *theSearchBar;
- (void)searchBar:(UISearchBar *)searchBar activate:(BOOL) active;
@end
SearchViewController.m 如下:
//
// SearchViewController.m
//
#import "SearchViewController.h"
@implementation SearchViewController
@synthesize tableData;
@synthesize disableViewOverlay;
@synthesize theSearchBar;
@synthesize theTableView;
// Initialize tableData and disabledViewOverlay
- (void)viewDidLoad {
[super viewDidLoad];
self.tableData =[[NSMutableArray alloc]init];
self.disableViewOverlay = [[UIView alloc]
initWithFrame:CGRectMake(0.0f,44.0f,320.0f,416.0f)];
self.disableViewOverlay.backgroundColor=[UIColor blackColor];
self.disableViewOverlay.alpha = 0;
}
// Since this view is only for searching give the UISearchBar
// focus right away
- (void)viewDidAppear:(BOOL)animated {
[self.theSearchBar becomeFirstResponder];
[super viewDidAppear:animated];
}
#pragma mark -
#pragma mark UISearchBarDelegate Methods
- (void)searchBar:(UISearchBar *)searchBar
textDidChange:(NSString *)searchText {
// We don't want to do anything until the user clicks
// the 'Search' button.
// If you wanted to display results as the user types
// you would do that here.
}
- (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar {
// searchBarTextDidBeginEditing is called whenever
// focus is given to the UISearchBar
// call our activate method so that we can do some
// additional things when the UISearchBar shows.
[self searchBar:searchBar activate:YES];
}
- (void)searchBarTextDidEndEditing:(UISearchBar *)searchBar {
// searchBarTextDidEndEditing is fired whenever the
// UISearchBar loses focus
// We don't need to do anything here.
}
- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar {
// Clear the search text
// Deactivate the UISearchBar
searchBar.text=@"";
[self searchBar:searchBar activate:NO];
}
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {
// Do the search and show the results in tableview
// Deactivate the UISearchBar
// You'll probably want to do this on another thread
// SomeService is just a dummy class representing some
// api that you are using to do the search
NSArray *results = [SomeService doSearch:searchBar.text];
[self searchBar:searchBar activate:NO];
[self.tableData removeAllObjects];
[self.tableData addObjectsFromArray:results];
[self.theTableView reloadData];
}
// We call this when we want to activate/deactivate the UISearchBar
// Depending on active (YES/NO) we disable/enable selection and
// scrolling on the UITableView
// Show/Hide the UISearchBar Cancel button
// Fade the screen In/Out with the disableViewOverlay and
// simple Animations
- (void)searchBar:(UISearchBar *)searchBar activate:(BOOL) active{
self.theTableView.allowsSelection = !active;
self.theTableView.scrollEnabled = !active;
if (!active) {
[disableViewOverlay removeFromSuperview];
[searchBar resignFirstResponder];
} else {
self.disableViewOverlay.alpha = 0;
[self.view addSubview:self.disableViewOverlay];
[UIView beginAnimations:@"FadeIn" context:nil];
[UIView setAnimationDuration:0.5];
self.disableViewOverlay.alpha = 0.6;
[UIView commitAnimations];
// probably not needed if you have a details view since you
// will go there on selection
NSIndexPath *selected = [self.theTableView
indexPathForSelectedRow];
if (selected) {
[self.theTableView deselectRowAtIndexPath:selected
animated:NO];
}
}
[searchBar setShowsCancelButton:active animated:YES];
}
#pragma mark -
#pragma mark UITableViewDataSource Methods
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section {
return [tableData count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyIdentifier = @"SearchResult";
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:MyIdentifier] autorelease];
}
id *data = [self.tableData objectAtIndex:indexPath.row];
cell.textLabel.text = data.name;
return cell;
}
#pragma mark -
#pragma mark Memory Management Methods
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[theTableView release], theTableView = nil;
[theSearchBar release], theSearchBar = nil;
[tableData dealloc];
[disableViewOverlay dealloc];
[super dealloc];
}
@end
最新技术文章: