点击按钮后出现黑屏

时间:2015-12-02 04:02:53

标签: ios objective-c viewcontroller

我对Objective-C很新。我想去另一个视图控制器,但它只显示按钮点击后的黑屏。我有什么东西在这里缺席吗?

这是我的代码:

- (IBAction)measuring1stscan:(id)sender {
    measuringscan *second = [[measuringscan alloc]initWithNibName:nil bundle:nil];
    [self presentViewController:second animated:NO completion:NULL];
}

* measuringscan是另一个视图控制器的名称

3 个答案:

答案 0 :(得分:0)

viewConreoller默认是没有颜色,它是黑色的。只需添加second.view.backgroundColor = [UIColor redColor];

即可
 - (IBAction)measuring1stscan:(id)sender {
measuringscan *second = [[measuringscan alloc] init];
second.view.backgroundColor = [UIColor redColor];
[self presentViewController:second animated:NO completion:NULL];
}

答案 1 :(得分:0)

@rose是正确的尝试给出不同的颜色,然后检查。

你仍然面临同样的问题,然后尝试在代码下运行。

将视图控制器嵌入到导航控制器中,并为第二个视图控制器提供唯一标识符。

{!! $site->description !!}

答案 2 :(得分:0)

如果您使用的是故事板,请使用以下

function InsertEmailMessage() {
$explode_check=explode(',', $_POST['ticked']);
//print_r($explode_check);
//$to[]= $row6['PersoninCharge'];

$messages = array();

for($i=0;$i<count($explode_check);$i++)
{
    $Selcheckb=$explode_check[$i];

    $sql6 = "SELECT * FROM invalid_invoice WHERE ID=:cb";
    $conn = dbConnect();
    $stmt6->bindParam(':cb', $Selcheckb);
    $stmt6 = $conn->prepare($sql6);
    $stmt6->execute();

    $data = $stmt6->fetchAll(PDO::FETCH_ASSOC);

    //var_dump($data);

    foreach ($data as $row6) {

        $invnumb=$row6['Invoice_Number'];
        $partnumb=$row6['Part_Number'];
        $issue=$row6['Issues'];
        $pic=$row6['PIC_Comments'];
        $issuetype=$row6['Issue_Type'];
        $createdate=$row6['Creation_Date'];
        $site=$row6['Site'];
        $vendor=$row6['Vendor_Name'];
        $invdate=$row6['Invoice_Date'];
        $po=$row6['PO'];
        $rr=$row6['RR'];
        $currency=$row6['Currency'];
        $invamount=$row6['Invoice_Amount'];
        $stat=$row6['Status'];
        $to[]=$row6['PersoninCharge'];
        $emailadd=explode(",", $to);


        if($row6['Status']=="Open") {
            if(!isset($messages[$emailadd])) {
              $messages[$emailadd] = '';
            }

            $messages[$emailadd] .= "<b>Issue Type: {$issuetype} </b><br><br>";
            $messages[$emailadd] .= "<b>Creation Date: {$createdate} </b><br><br>";
            $messages[$emailadd] .= "<b>Site: {$site} </b><br><br>";
            $messages[$emailadd] .= "<b>Vendor Name: {$vendor} </b><br><br>";
            $messages[$emailadd] .= "<b>Invoice Date: {$invdate} </b><br><br>";
            $messages[$emailadd] .= "<b>Invoice Number: {$invnumb} </b><br><br>";
            $messages[$emailadd] .= "<b>Part Number:</b><br>{$partnumb}<br><br>";
            $messages[$emailadd] .= "<b>PO: {$po} </b><br><br>";
            $messages[$emailadd] .= "<b>RR: {$rr} </b><br><br>";
            $messages[$emailadd] .= "<b>Currency: {$currency} </b><br><br>";
            $messages[$emailadd] .= "<b>Invoice Amount: {$invamount} </b><br><br>";
            $messages[$emailadd] .= "<b>Issues:</b><br>{$issue}<br>";
            $messages[$emailadd] .= "<b>Status: {$stat} </b><br><br>";
            $messages[$emailadd] .= "<b>{$pic}<b><br>";
            $messages[$emailadd] .= "<br><br>";

        }
    }
}

foreach($messages as $email=>$message) {
    dbInsertEmailMessage($email, "Invalid Invoice Tracking Message", "<html>{$message}</html>");
    echo "<script language='javascript'>alert('Email sent to {$email}.')</script>";
}

$conn=null;
}


function dbInsertEmailMessage($send_to, $subject, $message) {

        $sql7 = "INSERT INTO email_queue (send_to, subject, message) 
            VALUES (:send_to, :subject, :message)"; 
        $conn = dbConnect();
        $stmt7 = $conn->prepare($sql7); 
        $stmt7->bindParam(':send_to', $send_to);
        $stmt7->bindParam(':subject', $subject);
        $stmt7->bindParam(':message', $message);
        $stmt7->execute();
        $conn=null; 
        }

measuringscan *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"StoryboardIdentifier"];
[self presentViewController:controller animated:YES completion:nil];

如果你没有使用故事板,而是使用xib,那么使用以下

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:[NSString stringWithFormat:@"StoryboardName"] bundle:nil];
measuringscan *controller = [storyboard instantiateViewControllerWithIdentifier:@"viewcontroller'sIdentifier"];     
[self presentViewController:controller animated:YES completion:nil];

要记住的要点(正如@rmaddy所说)

  • 班级名称应以大写字母
  • 开头
  • 变量名称应以小写字母开头

这是开发人员应该遵循的命名约定。

有关详细信息click here