void RootWindow::keyBackClicked() { if (this->getModalViewController()) { this->dismissModalViewController(true); } else if (this->getDrawerController()->isShowLeftViewController()) { this->getDrawerController()->hideLeftViewController(true); } else if (this->getRootNavigationController()->getViewControllerCount() > 1) { this->getRootNavigationController()->popViewControllerAnimated(true); } else if (this->getRootTabBarController()->getSelectedViewController()->isEqual(m_pSecondNavigationController) && this->getSecondNavigationController()->getViewControllerCount() > 1) { this->getSecondNavigationController()->popViewControllerAnimated(true); } else { CC_RETURN_IF(m_bAlertShow); m_bAlertShow = true; CAAlertView* alertView = CAAlertView::createWithText("提示", "确定要退出?", "确定", "取消", NULL); alertView->setTarget(this, CAAlertView_selector(RootWindow::onAlertView)); alertView->show(); } }
void FSNewsView2::onClickBookMark(CAControl* btn, CCPoint point) { //加入标签 BookMarkInfo *bookmarkinfo = new BookMarkInfo(); ChapterInfo *curChapterInfo = FSDataManager::GetInstance().getNewsManager()->getCurChapterInfo(); // int dff= this->getChapterInfo()->getNewsID(); bookmarkinfo->setChapterID(curChapterInfo->getChapterID()); bookmarkinfo->setNewsID(curChapterInfo->getNewsID()); string strMarkDigest; // if (curFSNewsView2->getCurContent().length()>10) { // strMarkDigest = curFSNewsView2->getCurContent().substr(0,10); // } // else // { // strMarkDigest = m_curContent; // } int curPage = curFSNewsView2->listView->getCurrPage(); bookmarkinfo->setMarkDigest(curFSNewsView2->getDigestForMark()); double contentSize = (double)curFSNewsView2->m_aryContent.size(); double curPageDouble = (double)(curPage+1); double chapterPrecent = curPageDouble/contentSize; chapterPrecent = roundEx(chapterPrecent, 4); // double chapterPrecent = 1; char chrChapterPrecent[50] = ""; sprintf(chrChapterPrecent,"%.4lf",chapterPrecent); bookmarkinfo->setMarkProgress(chrChapterPrecent); bool flag = FSDataManager::GetInstance().getNewsManager()->addBookMarkInfo(bookmarkinfo); string strTitle = "提示"; string strClose="关闭"; string strContent; if (!flag) { //加入失败 strContent = "已经有重复的标签"; } else { strContent = "添加标签成功"; } CAAlertView* alertView = CAAlertView::createWithText(strTitle.c_str(), strContent.c_str(), strClose.c_str(),NULL); alertView->show(); }
CAAlertView *CAAlertView::create() { CAAlertView *pAlert = new CAAlertView(); if (pAlert && pAlert->init()) { pAlert->autorelease(); return pAlert; } CC_SAFE_DELETE(pAlert); return pAlert; }
void AlertViewTest::respondTouch(CAControl* btn ,CCPoint point) { CCSize size = this->getView()->getBounds().size; std::vector<std::string> btnTitle; CAAlertView* alertView = CAAlertView::create(); btnTitle.push_back("green"); btnTitle.push_back("yeelow"); btnTitle.push_back("orange"); alertView->showMessage("ButtonImage", "What kind of background of button do you like?", btnTitle); alertView->setTarget(this, CAAlertView_selector(AlertViewTest::alertViewCallback)); }
void FirstViewController::diss(CAControl* sender, CCPoint point) { this->dismissModalViewController(true); CAAlertView* alert = CAAlertView::create(); std::vector<std::string> s; for (int i = 0; i < CCRANDOM_0_1() * 5; i++) { char str[10]; sprintf(str, "button_%d", i); s.push_back(str); } alert->showMessage("title", "message", s); }
void huaFeiViewController::onRequestFinished(const HttpResponseStatus &status, const CSJson::Value &json){ if (status == HttpResponseSucceed) { // const CSJson::Value& code = json["code"]; const CSJson::Value& value = json["msg"]; CCLog("str = %s", value.asString().c_str()); CAAlertView* alertView = CAAlertView::createWithText("提示", value.asString().c_str(), "close",NULL); alertView->show(); } }
CAAlertView *CAAlertView::createWithText(const char* pszTitle, const char* pszAlertMsg, const char* pszBtnText, ...) { va_list args; va_start(args, pszBtnText); CAAlertView *pAlert = new CAAlertView(); if (pAlert && pAlert->init()) { pAlert->addButton(pszBtnText); const char* pszText = va_arg(args, const char*); while (pszText) { pAlert->addButton(pszText); pszText = va_arg(args, const char*); } va_end(args); pAlert->setTitle(pszTitle, CAColor_black); pAlert->setAlertMessage(pszAlertMsg); pAlert->autorelease(); return pAlert; }