Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Bayan

macrumors newbie
Original poster
Apr 13, 2012
23
0
When I run my app and press the button that takes me to the page Jaw, a blank black screen is displayed instead. I don't get any kind of run error or anything in my log. When I added an NSLog to the ViewDidLoad to check if the method is evoked, nothing is displayed in my log! Does anyone know what is causing this?

This is the code of the page "Jaw",
.h:
Code:
#import <UIKit/UIKit.h>
#import <sqlite3.h>
#import "ViewController.h"
#import "NewCase.h"
#import "Info.h"
#import "Needed.h"
#import "Available.h"
#import "import.h"
#import "Result.h"
#import "Ps.h"
#import "Patiant.h"

@interface Jaws : UIViewController <UINavigationControllerDelegate>
{
    sqlite3 *database;
    NSString *file;
}
@property (retain, nonatomic) NSString *file;
@property (strong, nonatomic) IBOutlet UIView *view;
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
@property (weak, nonatomic) IBOutlet UILabel *UpperT;
@property (weak, nonatomic) IBOutlet UIImageView *Upper;
@property (weak, nonatomic) IBOutlet UILabel *LowerT;
@property (weak, nonatomic) IBOutlet UIImageView *Lower;
@property (weak, nonatomic) IBOutlet UIBarButtonItem *Back;
- (IBAction)Back:(id)sender;
-(void)retrieve;
@end
.m
Code:
#import "Jaws.h"

@interface Jaws ()

@end

@implementation Jaws
@synthesize Upper, Lower, file, scrollView, Back, UpperT, LowerT, view;
NewCase *new;

-(BOOL) respondsToSelector:(SEL)aSelector {
    printf("SELECTOR: %s\n", [NSStringFromSelector(aSelector) UTF8String]);
    return [super respondsToSelector:aSelector];
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self)
    {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self retrieve];
    
    [scrollView setContentSize:CGSizeMake(340, 1000)];
    // Do any additional setup after loading the view from its nib.
}

- (void)viewDidUnload
{
    [self setScrollView:nil];
    [self setBack:nil];
    [self setUpper:nil];
    [self setLower:nil];
    [self setUpperT:nil];
    [self setLowerT:nil];
    [self setView:nil];
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

-(void)retrieve
{
    int type;
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *path = [documentsDirectory stringByAppendingPathComponent:@"TTSData.sql"];
    
    if (sqlite3_open([path UTF8String], &database) == SQLITE_OK) 
    {
        NSString *presql = [ NSString stringWithFormat:@"SELECT * FROM Jaw WHERE file = '%d' ", [file intValue]];
        const char *sql = [presql UTF8String];
        sqlite3_stmt *searchStatement;
        
        if (sqlite3_prepare_v2(database, sql, -1, &searchStatement, NULL) == SQLITE_OK) 
        {
            while (sqlite3_step(searchStatement) == SQLITE_ROW) 
            {
                UIImage *jaw = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithUTF8String:(char *)sqlite3_column_text(searchStatement, 0)]];
                
                type = sqlite3_column_int(searchStatement, 2);
                Upper.image= jaw;
                
                if ([new.JType isEqualToString:@"0"])
                {
                    LowerT.text = @"NO Lower Jaw";
                }
                
                else if ([new.JType isEqualToString:@"1"])
                {
                    UpperT.text = @"Lower Jaw";
                    LowerT.text = @"NO Upper Jaw";
                }
                
                else
                {
                    Upper.image= jaw;
                    Lower.image= jaw;
                }
            }
        }
    }
}

- (IBAction)Back:(id)sender
{
    Patiant *a = [[Patiant alloc] initWithNibName:nil bundle:nil]; 
    a.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self presentModalViewController:a animated:YES];
}
@end
 
Last edited:
This is it:
Code:
Jaws *i = [[Jaws alloc] initWithNibName:nil bundle:nil]; 
    i.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    [self presentModalViewController:i animated:YES];
 
That's not what he's looking for.

He wants the code of the method that is called when the button that summons the Jaws view is called.
 
Yes, what I've posted is what's inside the method.
Code:
- (IBAction)Info:(id)sender
{
    Jaws *i = [[Jaws alloc] initWithNibName:nil bundle:nil]; 
    i.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    [self presentModalViewController:i animated:YES];
}

There's also another method in another page that calls Jaws:
Code:
- (IBAction)ViewJaws:(id)sender
{
    Jaws *i = [[Jaws alloc] initWithNibName:nil bundle:nil];
    i.file = file;
    i.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    [self presentModalViewController:i animated:YES];
}
 
How can I make sure of that?

I have the same code everywhere calling different view controllers and it works. such as,
Code:
- (IBAction)NewCase:(id)sender
{
    NewCase *i = [[NewCase alloc] initWithNibName:nil bundle:nil]; 
    i.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    [self presentModalViewController:i animated:YES];
}

The Jaws code used to work before but I don't know what changed now, a black screen is displayed instead.
 
I would set a breakpoint in your viewDidLoad then and step-through it. How far does it get?

Nothing happens and when I included an NSLog line inside the method, there is no output. So I'm guessing the ViewDidLoad was never reached.

When I added breakpoints in the methods calling the view controllers, this is what I got:
2jezjpx.png


Someone told me to put the below method in all my .m that are causing the problem
Code:
-(BOOL) respondsToSelector:(SEL)aSelector {
    printf("SELECTOR: %s\n", [NSStringFromSelector(aSelector) UTF8String]);
    return [super respondsToSelector:aSelector];
}

when I added it to my Result.m and called the view controller, the following was output:
Code:
SELECTOR: _lastKnownInterfaceOrientation
SELECTOR: _completionBlock
SELECTOR: _didFinishPresentTransition

when I called the Jaws view controller, the output was:
Code:
SELECTOR: _lastKnownInterfaceOrientation
 
Yes, I have.

Did you create it at the same time as your Jaws class, using the "with XIB for user interface" option? If so, is it just black?

EDIT:

Another guess is that your retrieve method is holding up your main run-loop, therefore blocking your UI.
 
Did you create it at the same time as your Jaws class, using the "with XIB for user interface" option? If so, is it just black?

Yes and yes.

EDIT:

Another guess is that your retrieve method is holding up your main run-loop, therefore blocking your UI.

I commented the whole method and it still displays a black screen!

Thank you for your help dejo, I really appreciate every suggestion.
 
If so, is it just black?
What I mean by this: is the UI for your Jaws XIB empty except for a black background?

Although if you are calling presentModalViewController: and yet your viewDidLoad is not getting called that is a serious issue. One which I'm not entirely sure what could be causing that.
 
What I mean by this: is the UI for your Jaws XIB empty except for a black background?

No, it's not empty. It has a tool bar, a tab bar, text labels and two images.
I tried deleting them all where the view controller is just an empty UIView but the problem still remains.

The problem is happening in two of my classes although they BOTH used to work before!
 
The problem is happening in two of my classes although they BOTH used to work before!

I don't suppose you are using any kind of source-control-management and can review/revert any changes that you may have done?

What happens if you create a new Jaws-like viewController and use that instead? If that works, you may have to recreate Jaws.
 
I don't suppose you are using any kind of source-control-management and can review/revert any changes that you may have done?
You mean UNDO? if not, then no I don't know what source-control-management is.

What happens if you create a new Jaws-like viewController and use that instead? If that works, you may have to recreate Jaws.

I already tried that before even crating this thread. I created a new .h .m .xib with a different name but same code as Jaws.h, Jaws.m and Jaws.xib. It produces the same problem.
 
You mean UNDO? if not, then no I don't know what source-control-management is.
git, svn, cvs, etc. So, probably not.

Bayan said:
I already tried that before even crating this thread. I created a new .h .m .xib with a different name but same code as Jaws.h, Jaws.m and Jaws.xib. It produces the same problem.
Don't put in all the same code right away. Start with a only the most-basic code (i.e. that created by the File > New...) and change something simple but obvious, such as the background color for the view (red is usually pretty obvious!). Does that appear? Yes? Good. Add more pieces, bit-by-bit. No red view? Stop and diagnose the very simple code you've added.
 
I fixed it :)
Turns out there was a UIView property that wasn't needed.

Again, thanks for the help dejo.
 
What was the UIView property that wasn't needed? If you don't mind me asking.

Sorry for my late reply, I don't remember very well now but I think it was an empty UIView that I have added on top of my original view.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.