NSTouchBar with multi-level NSPopoverTouchBarItem - nstouchbar

I'm trying to make a simple NSTouchBar with 3 levels of NSPopoverTouchBarItem, so basically its like this:
I have the main NSTouchbar with 3 NSButton and 1 NSPopoverTouchBarItem which open the second NSTouchbar
The second NSTouchbar with 2 NSButton and 1 NSPopoverTouchBarItem which open the third NSTouchbar
The problem is when i try open the 3rd NSTouchbar, seems like the 2nd NSTouchbar is dismissed, and sometimes doesn't open the 3rd.
Also when opens the third one, when we close, we go to 1st NSTouchbar, not the 2nd NSTouchbar
Here is the code, should be simple, and should work (i'm using Xcode TouchBar Simulator)
#import "Window.h"
static NSTouchBarCustomizationIdentifier TouchBarCustomizationIdentifier = #"TouchBarCustomizationIdentifier";
static NSTouchBarItemIdentifier NSTouchBarItemIdentifier1 = #"NSTouchBarItemIdentifier1";
static NSTouchBarItemIdentifier NSTouchBarItemIdentifier2 = #"NSTouchBarItemIdentifier2";
static NSTouchBarItemIdentifier NSTouchBarItemIdentifier3 = #"NSTouchBarItemIdentifier3";
static NSTouchBarItemIdentifier NSTouchBarItemIdentifier4 = #"NSTouchBarItemIdentifier4";
static NSTouchBarItemIdentifier NSTouchBarItemIdentifier4_1 = #"NSTouchBarItemIdentifier4_1";
static NSTouchBarItemIdentifier NSTouchBarItemIdentifier4_2 = #"NSTouchBarItemIdentifier4_2";
static NSTouchBarItemIdentifier NSTouchBarItemIdentifier4_3 = #"NSTouchBarItemIdentifier4_3";
static NSTouchBarItemIdentifier NSTouchBarItemIdentifier4_3_1 = #"NSTouchBarItemIdentifier4_3_1";
static NSTouchBarItemIdentifier NSTouchBarItemIdentifier4_3_2 = #"NSTouchBarItemIdentifier4_3_2";
#implementation Window
- (NSTouchBar*) makeTouchBar {
_touchBar1 = [[NSTouchBar alloc] init];
[_touchBar1 setDelegate:self];
[_touchBar1 setCustomizationIdentifier:TouchBarCustomizationIdentifier];
[_touchBar1 setDefaultItemIdentifiers:#[
NSTouchBarItemIdentifier1,
NSTouchBarItemIdentifier2,
NSTouchBarItemIdentifier3,
NSTouchBarItemIdentifier4,
]
];
[_touchBar1 setCustomizationRequiredItemIdentifiers:#[
NSTouchBarItemIdentifier1,
NSTouchBarItemIdentifier2,
NSTouchBarItemIdentifier3,
NSTouchBarItemIdentifier4,
]
];
return _touchBar1;
}
- (nullable NSTouchBarItem *)touchBar:(NSTouchBar *)touchBar makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier {
if ([identifier isEqual:NSTouchBarItemIdentifier1]) {
NSCustomTouchBarItem *customTouchBarItem = [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier];
[customTouchBarItem setView:[NSButton buttonWithTitle:#"IS TOUCH 1" target:self action:nil]];
return customTouchBarItem;
} else if ([identifier isEqual:NSTouchBarItemIdentifier2]) {
NSCustomTouchBarItem *customTouchBarItem = [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier];
[customTouchBarItem setView:[NSButton buttonWithTitle:#"IS TOUCH1" target:self action:nil]];
return customTouchBarItem;
} else if ([identifier isEqual:NSTouchBarItemIdentifier3]) {
NSCustomTouchBarItem *customTouchBarItem = [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier];
[customTouchBarItem setView:[NSButton buttonWithTitle:#"IS TOUCH1" target:self action:nil]];
return customTouchBarItem;
} else if ([identifier isEqual:NSTouchBarItemIdentifier4]) {
NSPopoverTouchBarItem *customTouchBarItem = [[NSPopoverTouchBarItem alloc] initWithIdentifier:identifier];
[customTouchBarItem setCollapsedRepresentationLabel:#"OPEN TOUCH 2"];
_touchBar2 = [[NSTouchBar alloc] init];
[_touchBar2 setDelegate:self];
[_touchBar2 setCustomizationIdentifier:TouchBarCustomizationIdentifier];
[_touchBar2 setDefaultItemIdentifiers:#[
NSTouchBarItemIdentifier4_1,
NSTouchBarItemIdentifier4_2,
NSTouchBarItemIdentifier4_3,
]
];
[_touchBar2 setCustomizationRequiredItemIdentifiers:#[
NSTouchBarItemIdentifier4_1,
NSTouchBarItemIdentifier4_2,
NSTouchBarItemIdentifier4_3,
]
];
[customTouchBarItem setPopoverTouchBar:_touchBar2];
return customTouchBarItem;
} else if ([identifier isEqual:NSTouchBarItemIdentifier4_1]) {
NSCustomTouchBarItem *customTouchBarItem = [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier];
[customTouchBarItem setView:[NSButton buttonWithTitle:#"IS TOUCH 2" target:self action:nil]];
return customTouchBarItem;
} else if ([identifier isEqual:NSTouchBarItemIdentifier4_2]) {
NSCustomTouchBarItem *customTouchBarItem = [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier];
[customTouchBarItem setView:[NSButton buttonWithTitle:#"IS TOUCH 2" target:self action:nil]];
return customTouchBarItem;
} else if ([identifier isEqual:NSTouchBarItemIdentifier4_3]) {
NSPopoverTouchBarItem *customTouchBarItem = [[NSPopoverTouchBarItem alloc] initWithIdentifier:identifier];
[customTouchBarItem setCollapsedRepresentationLabel:#"OPEN TOUCH 3"];
_touchBar3 = [[NSTouchBar alloc] init];
[_touchBar3 setDelegate:self];
[_touchBar3 setCustomizationIdentifier:TouchBarCustomizationIdentifier];
[_touchBar3 setDefaultItemIdentifiers:#[
NSTouchBarItemIdentifier4_3_1,
NSTouchBarItemIdentifier4_3_2,
]
];
[_touchBar3 setCustomizationRequiredItemIdentifiers:#[
NSTouchBarItemIdentifier4_3_1,
NSTouchBarItemIdentifier4_3_2,
]
];
[customTouchBarItem setPopoverTouchBar:_touchBar3];
return customTouchBarItem;
} else if ([identifier isEqual:NSTouchBarItemIdentifier4_3_1]) {
NSCustomTouchBarItem *customTouchBarItem = [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier];
[customTouchBarItem setView:[NSButton buttonWithTitle:#"IS TOUCH 3" target:self action:nil]];
return customTouchBarItem;
} else if ([identifier isEqual:NSTouchBarItemIdentifier4_3_2]) {
NSCustomTouchBarItem *customTouchBarItem = [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier];
[customTouchBarItem setView:[NSButton buttonWithTitle:#"IS TOUCH 3" target:self action:nil]];
return customTouchBarItem;
}
return nil;
}
#end

Apple says popovers cannot have popovers, so you can only have a bar and a popover, not a popover inside a popover.
This is what they have posted in their forum to answer a similar question:
https://forums.developer.apple.com/thread/78730

Related

Combining a TabBar and Navigation Controller IOS8

I'm new to iOS and I have troubles to display a navigation controller in my taBbar after Xcode 6 update.
With Xcode 5, it was working perfectly but now on the simulator I get an error message "Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing a navigation controller is not supported'" and the app crashes.
Here is my code:
**appDelegate.m**
- (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:
(NSDictionary *)launchOptions{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor =[UIColor whiteColor];
[self.window makeKeyAndVisible];
*// tabBar items*
ItemUnViewController *itemUnViewController = [[ItemUnViewController alloc]
initWithNibName:nil
bundle:NULL];
ItemDeuxViewController *itemDeuxViewController = [[ItemDeuxViewController alloc]
initWithNibName:nil
bundle:NULL];
*//tabBar*
UITabBarController *tabBarController = [[UITabBarController alloc] init];
[tabBarController setViewControllers:#[itemUnViewController,itemDeuxViewController]];
*//setting tabBar as rootView*
self.window.rootViewController = tabBarController;
*// navigation Controllers*
UINavigationController *itemUnNavigationController =
[[UINavigationController alloc]
initWithRootViewController:itemUnViewController];
UINavigationController *itemDeuxNavigationController =
[[UINavigationController alloc]
initWithRootViewController:itemDeuxViewController];
*//Combining tabBar and Navigation Controllers*
[tabBarController setViewControllers:#
[itemUnNavigationController,itemDeuxNavigationController]];
return YES;
}
I even tried this way http://blog.rifkilabs.net/exploring-navigation-controller-and-tab-bar-controller.html but i get the same error message.
Thanks for your help.
tabBar_Controller = [[UITabBarController alloc]init];
[tabBar_Controller setDelegate:self];
ViewController1 *obj_1 = [obj_story instantiateViewControllerWithIdentifier:#"VC1"];
UINavigationController *navi_vc1 = [[UINavigationController alloc]initWithRootViewController:obj_1];
navi_vc1.navigationBarHidden = YES;
ViewController2 *obj_2 = [obj_story instantiateViewControllerWithIdentifier:#"VC2"];
UINavigationController *navi_vc2 = [[UINavigationController alloc]initWithRootViewController:obj_2];
navi_vc2.navigationBarHidden = YES;
[tabBar_Controller setViewControllers:[NSArray arrayWithObjects:navi_vc1,navi_vc2,nil]];
//Hide Tabbar View Controller.//
[self hideTabBar]
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-(void) hideTabBar
{
for(UIView *view in tabBar_Controller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, [UIScreen mainScreen].bounds.size.height, view.frame.size.width, view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, [UIScreen mainScreen].bounds.size.height)];
}
}
}
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-(void)create_BottomBarButton
{
UIView *viewBottom = (UIView *)[self.window viewWithTag:Tag_BottomView];
if (viewBottom == nil)
{
#try
{
viewBottom = [[UIView alloc]init];
[viewBottom setFrame:CGRectMake([UIScreen mainScreen].bounds.origin.x, [UIScreen mainScreen].bounds.size.height-(HeightOfBottomBar+KsubviewHeight), [UIScreen mainScreen].bounds.size.width, HeightOfBottomBar)];
[viewBottom setBackgroundColor:RGB(47.0, 45.0, 45.0, 1.0)];
[viewBottom setTag:Tag_BottomView];
NSArray *arrImage = [NSLocalizedString(#"arrBottomBarImgs", nil)componentsSeparatedByString:#","];
float x = 0.0;
for (int i =0; i < kTotalTab; i++) {
[self create_TabBtn:viewBottom frame:CGRectMake(x, 0, 62,62) withTag:i+1 withImage:[arrImage objectAtIndex:i]];
x += 64.5;
}
[self.window addSubview:viewBottom];
}
#catch (NSException *exception)
{
NSLog(#"EXCEPTON %#",[exception description]);
}
}
}
-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-
-(void)select_Tab:(UIButton *)btn
{
#try {
[[tabBar_Controller.viewControllers objectAtIndex:btn.tag-1] popToRootViewControllerAnimated:YES];
[tabBar_Controller setSelectedIndex:btn.tag-1];
}
#catch (NSException *exception) {
NSLog(#"%s",__PRETTY_FUNCTION__);
}
}
-=-=-=-=-=-=-=-=-=-=-=-=-=-
-(void)pushTabBarIntoNavigationBar
{
[navi setNavigationBarHidden:YES];
[[UIApplication sharedApplication] setStatusBarHidden:NO];
[navi pushViewController:tabBar_Controller animated:YES];
}
-=-=-=-=-=-=-=-=-=-=-=
navi = [[UINavigationController alloc]initWithRootViewController:tabBar_Controller];
[navi setNavigationBarHidden:YES];
self.window.rootViewController = navi;

Method cellForRowAtIndexPath method was not get called

Am a beginner in iOS, am creating an application with the help of table view. I just run my application, while running the app, the app does not calling the method cellForRowIndexPath. Am using Json as web service. In the output screen, the parsing data is shown but it is not get display in simulator. i put breakpoint and i understood the cellForRowIndexPath path was not called. I drag datasourse and data delegate to files onner of xib file. but nothing is occurring... the table view is get displaying but there is no content... am screwed.. Any one please help me...
#implementation MSPackagesController
#synthesize packageTable;
#synthesize packages;
#synthesize mainCtrl;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
-(void)viewDidLoad
{
[super viewDidLoad];
}
-(void)parseData {
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.animationType = MBProgressHUDAnimationFade;
hud.detailsLabelText = #"Loading...";
MSJsonParser *parser = [[MSJsonParser alloc]initWithParserType:kPackagesParsing];
parser._parserSource = self;
[parser requestParsingWithUrl:PACKAGES_LIST_URL];
}
-(void)sharePackageFromCell:(UIButton*)btn
{
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.animationType = MBProgressHUDAnimationFade;
hud.detailsLabelText = #"Loading...";
NSString *title = [[self.packages objectAtIndex:btn.tag] packageName];
/*NSURL *imgUrl = [NSURL URLWithString:[[self.promotions objectAtIndex:btn.tag] picture]];
NSData *imgdata = [NSData dataWithContentsOfURL:imgUrl];
UIImage *image = [UIImage imageWithData:imgdata];*/
// NSURL *imgUrl = [NSURL URLWithString:[[self.packages objectAtIndex:btn.tag] picture]];
NSString *desc = [[self.packages objectAtIndex:btn.tag] packageDescription];
NSString *message = #"Visit GlamZapp in AppStore";
UIActivityViewController *activityCtrl = [[UIActivityViewController alloc]initWithActivityItems:[NSArray arrayWithObjects:title,desc,message, nil] applicationActivities:nil];
activityCtrl.excludedActivityTypes = #[UIActivityTypePrint,UIActivityTypePostToWeibo,UIActivityTypeMessage,UIActivityTypeAssignToContact];
activityCtrl.completionHandler = ^(NSString *activityType, BOOL completed)
{
NSLog(#" activityType: %#", activityType);
NSLog(#" completed: %i", completed);
};
[self.mainCtrl presentViewController:activityCtrl animated:YES completion:^{
[MBProgressHUD hideAllHUDsForView:self.view animated:YES];
}];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#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 [packages count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"Cell";
MSPackagesCell *cell = (MSPackagesCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *cells = [[NSBundle mainBundle]loadNibNamed:[Common checkDeviceforController:#"MSPackagesCell"] owner:nil options:nil];
for (id eachObject in cells) {
cell = eachObject;
break;
}
//cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
// Configure the cell...
// NSURL *imgUrl = [NSURL URLWithString:[[self.promotions objectAtIndex:indexPath.row]picture]];
//[cell.promoImg setImageWithURL:imgUrl placeholderImage:[UIImage imageNamed:#"slider_dummy.jpg"] andSize:cell.promoImg.frame.size];
cell.PackageName.text = [[self.packages objectAtIndex:indexPath.row] packageName];
cell.PackageDescription.text = [[self.packages objectAtIndex:indexPath.row] packageDescription];
// NSMutableAttributedString *strikedPrice = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:#"%# %#",CURRENCY_UNIT,[[self.packages objectAtIndex:indexPath.row] packageAmount] ] ];
// [strikedPrice addAttribute:NSStrikethroughStyleAttributeName value:[NSNumber numberWithInt:2] range:NSMakeRange(0, [strikedPrice length])];
//cell.oldPriceLabel.attributedText = strikedPrice;
cell.PriceLabel.text = [NSString stringWithFormat:#"%# %#",CURRENCY_UNIT,[[self.packages objectAtIndex:indexPath.row] packageAmount] ];
//[string appendFormat:#"%#\r\n", message];
// cell.promocodelabel.text = [NSString stringWithFormat:#"Promo code: %#",[[self.packages objectAtIndex:indexPath.row] promoCode]];
cell.ShareButton.tag = indexPath.row;
[cell.ShareButton addTarget:self action:#selector(sharePackageFromCell:) forControlEvents:UIControlEventTouchUpInside];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// MSPackageDetailsController *promDet = [[MSPackageDetailsController alloc]initWithNibName:[Common checkDeviceforController:#"MSPackageDetailsController"] bundle:nil];
// promDet.delegate = self;
// promDet.offerId = [[self.packages objectAtIndex:indexPath.row] promoId];
// promDet.title = [[self.packages objectAtIndex:indexPath.row] promoTitle];
// [self.delegate didSelectPromotion:promDet];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
-(void)foundPackagesData:(NSArray *)packa
{
[MBProgressHUD hideAllHUDsForView:self.view animated:YES];
self.packages = packa;
[self.packageTable reloadData];
}
-(void)connectionFailed
{
[MBProgressHUD hideAllHUDsForView:self.view animated:YES];
}
I think you have not added UITableviewDataSource and UITableViewDelegate in your .h file
Add UITableViewDataSource,UITableViewDelegate in interface (.h) file
#interface MSPackagesController : UIViewController <UITableViewDataSource,UITableViewDelegate>

SQlite Database ios UITableView

I Have Change the Whole Database...
Now I Have Two Tables that Display Below
First Table:- Category Table
Cat_id CategoryName
====================================
1 Jesus
2 Buddha
3 BillGates
Second Table :- SayingTable
Say_id Cat_id Sayings
===================================
1 1 Never Say False
2 1 God Bless you
3 1 Be a Good Boy
4 2 Make a Peaceful World
5 2 Never Lie with the People
and I Have Used UITableView in My Firstview Controller
That Display Like Below Image
When i Click on Jesus Christ Cell..Or any Other cell then it Crash..
My Code is Below
FirstViewController.m
- (void)viewDidLoad
{
dataaray = [[NSMutableArray alloc] init];;
[dataaray addObject:#"Jesus Christ"];
[dataaray addObject:#"Budhdha"];
[dataaray addObject:#"BillGates"];
jesus = [[NSMutableArray alloc] init];
Buddha = [DatabaseOperation SelectCategory:2];
Buddha = [Buddha valueForKey:#"Saying"];
NSLog(#"Buddha Bhagwan Category=%#",Buddha);
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [self.dataaray count];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *identifier = #"Cellidentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
if (cell==nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
cell.textLabel.text = [dataaray objectAtIndex:indexPath.row];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
DetailViewController *mydetail = [[DetailViewController alloc] initWithNibName:#"DetailViewController" bundle:nil];
if ([[dataaray objectAtIndex:indexPath.row] isEqual:#"Jesus Christ"])
{
mydetail.flag=1;
int SelectedRow = (indexpath.row+1);
jesus = [DatabaseOperation SelectCategory:SelectedRow];
jesus = [jesus valueForKey:#"Saying"];
NSLog(#"Jesus Category===%#",jesus);
mydetail.Jesus2Array = [jesus mutablecopy]; //Note Jesus2 is an Array of detailviewcontroller
}
else if ([[dataaray objectAtIndex:indexPath.row] isEqualToString:#"Budhdha"])
{
mydetail.flag=2;
SelectedRow = (indexpath.row+1);
Buddha = [DatabaseOperation SelectCategory:SelectedRow];
jesus = [jesus valueForKey:#"Saying"];
NSLog(#"Jesus Category===%#",jesus);
mydetail.Buddha2Array = [Buddha mutableCopy]; //Note Jesus2 is an Array of detailviewcontroller
}
DetailviewController.m
- (void)viewDidLoad
{
NSLog(#"Flag Value===%d",flag);
NSLog(#"Jesus 2 Array===%#",Jesus2Array);
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (flag==1)
{
return [Jesus2Array count];
}
if(flag==2)
{
return [Buddha2array count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
if (flag==1)
{
cell.textLabel.text = [Jesus2Array objectAtIndex:indexPath.row];
}
DatabaseOperation.h
#import <Foundation/Foundation.h>
#import "DatabaseOperation.h"
#import <sqlite3.h>
#interface DatabaseOperation : NSObject
{
}
+(void)Check_Create_Database;
+(NSMutableArray*)SelectCategory:(int)Category_id;
DatabaseOperation.m
#import "DatabaseOperation.h"
#import <sqlite3.h>
static NSString *dbPath;
static NSString *databaseName=#"Message.sqlite";
#implementation DatabaseOperation
+(void)Check_Create_Database
{
dbPath =[[NSHomeDirectory() stringByAppendingPathComponent:#"Documents"] stringByAppendingPathComponent:databaseName];
BOOL success;
NSFileManager *fm=[NSFileManager defaultManager];
success=[fm fileExistsAtPath:dbPath];
if(success){
return;
}
NSString *dbPathFromApp=[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:databaseName];
NSLog(#"dbPathFromApp = %#",dbPathFromApp);
[fm copyItemAtPath:dbPathFromApp toPath:dbPath error:nil];
}
+(NSMutableArray*)SelectCategory:(int)Category_id
//+(NSMutableArray*)SelectedCategory
{
sqlite3 *database;
NSMutableArray *dic=[[NSMutableArray alloc] init];
NSString *SAYING;
if(sqlite3_open([dbPath UTF8String] , &database) == SQLITE_OK)
{
NSString *sqlTmp=[NSString stringWithFormat:#"Select * from SayingTable Where Cat_id=%d",Category_id];
const char *sqlStmt=[sqlTmp UTF8String];
sqlite3_stmt *cmp_sqlStmt;
if(sqlite3_prepare_v2(database, sqlStmt, -1, &cmp_sqlStmt, NULL)==SQLITE_OK)
{
while(sqlite3_step(cmp_sqlStmt)==SQLITE_ROW)
{
NSLog(#"SQL Statements====%s",sqlStmt);
SAYING=[NSString stringWithUTF8String:(char *) sqlite3_column_text(cmp_sqlStmt, 2)];
NSMutableDictionary *dicObj=[[NSMutableDictionary alloc] init];
[dicObj setValue:[NSString stringWithFormat:#"%#",SAYING] forKey:#"Saying"];
[dic addObject: dicObj];
}
}
sqlite3_finalize(cmp_sqlStmt);
}
sqlite3_close(database);
When I Click the Cell then Detailview Controller is Not Loading.....i don't know whats Wrong in my Code Please Help..
Thank You...

GPUImageView Integration in my project

What I am trying to do is this.
- (void)viewDidLoad
{
[super viewDidLoad];
NSURL *url2 = [[NSBundle mainBundle] URLForResource:#"NAN" withExtension:#"mov"];
GPUImageMovie *movie2 = [[GPUImageMovie alloc] initWithURL:url2];
movie2.playAtActualSpeed = YES;
filter0 = [[GPUImageSepiaFilter alloc] init];
[movie2 addTarget:filter0];
[filter0 addTarget:view0]; // view0 is a GPUImageView taken in nib
[self recordVideo];
isRecording = YES;
[movie2 startProcessing];
[movieWriter setCompletionBlock:^{
if (isRecording) {
[self stopRecording];
isRecording = NO;
} }];
}
-(void)recordVideo {
NSString *path = [NSTemporaryDirectory() stringByAppendingPathComponent:#"file.mov"];
NSURL *url = [NSURL fileURLWithPath:path];
NSFileManager *fm = [NSFileManager defaultManager];
[fm removeItemAtPath:path error:nil];
movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:url size:CGSizeMake(640, 480)];
[filter0 addTarget:movieWriter];
[movieWriter startRecording];
}
-(void)stopRecording {
[movieWriter finishRecording];
}
But this is not working at all. I always get a black video with this code. There is no crash, I get a black video with the same duration as of original video. Has anyone faced the same issue. Kindly help.
Any help would be great.

i had some images in resultstring i want to display it in tableview

i had some images in resultstring ,resultstring is what i get from the server ,it contains images ,i want that images and display it in tableview
my code is
viewdidload
{
NSString *urlVal = #"http://at.azinova.info/green4care/iphone/viewImage.php?id=";
NSString *urlVal1 = [urlVal stringByAppendingString:selectedCountryw];
NSURL *url1 = [NSURL URLWithString:urlVal1];
//NSURL *url1 = [NSURL URLWithString:urlVal];
NSString *resultString = [NSString stringWithContentsOfURL:url1 encoding:NSUTF8StringEncoding error:nil];
NSArray *arycountries1 = [resultString componentsSeparatedByString:#","];
UIAlertView *loginalert = [[UIAlertView alloc] initWithTitle:#" Message" message:resultString delegate:self
cancelButtonTitle:#"OK" otherButtonTitles:nil];
[loginalert show];
[loginalert release];
//arraycountries = [[NSArray alloc]initWitho:arycountries1];
arraycountries = [[NSArray alloc]initWithArray: arycountries1];
}
- (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 [arraycountries count];
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.imageView.image = [UIImage imageNamed:[arraycountries objectAtIndex:indexPath.row]];
// Configure the cell...
return cell;
}
please help
thankzzzzz
What you described is much like a message borad with images, there is a twitter open source project tweetero: http://code.google.com/p/tweetero/ You can take a look at MessageListController and ImageLoader.
In generally, you could do like this:
1) Send async request to server to get message date(not images)
2) reload the table data, and send the image loader request for each uiimageview.
3) set the uiimageview when the image is loaded. A default loading image can be used until the real image is loaded.

Resources