小编Ome*_*erN的帖子

如何在Android中安排通知

我正试图在将来设置通知.我有创建通知的代码,但我找不到安排它的选项.

我该如何安排通知?

java notifications android android-notifications

31
推荐指数
2
解决办法
4万
查看次数

具有UIWebView动态高度的UITableViewCell

我有一个表格视图,其中包含webView的单元格,我希望单元格的高度与webView的高度相匹配.

这是我使用的代码:

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    let cell = tableView.dequeueReusableCellWithIdentifier("newsCell") as! NewsTableViewCell

    cell.webView.loadHTMLString("test<br>test<br>test<br>test<br>test<br>test", baseURL: nil)
    cell.webView.delegate = self

    var webFrame = cell.webView.frame
    var cellFrame = cell.frame
    cell.frame = CGRectMake(cellFrame.origin.x, cellFrame.origin.y, cellFrame.width, webFrame.height + 20)
    cell.backgroundColor = UIColor.redColor()

    return cell
}

func webViewDidFinishLoad(webView: UIWebView) {
    println("finished loading")
    var frame = webView.frame
    frame.size.height = 1
    webView.frame = frame

    var fittingSize = webView.sizeThatFits(CGSizeZero)
    frame.size = fittingSize
    webView.frame = frame

    var height: CGFloat = frame.height
    println(height)

    webView.frame = CGRectMake(frame.origin.x, …
Run Code Online (Sandbox Code Playgroud)

xcode uiwebview uitableview ios swift

19
推荐指数
2
解决办法
2万
查看次数

从 AlertDialog 返回一个值

我想构建一个函数来创建一个 AlertDialog 并返回用户输入的字符串,这是我用于创建对话框的函数,我如何返回值?

String m_Text = "";
private String openDialog(String title) {
    AlertDialog.Builder builder = new AlertDialog.Builder(view.getContext());
    builder.setTitle(title);

    final EditText input = new EditText(view.getContext());
    input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_NORMAL);
    builder.setView(input);

    builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            m_Text = input.getText().toString();
        }
    });
    builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });

    builder.show();

// return string
} 
Run Code Online (Sandbox Code Playgroud)

java android android-alertdialog

5
推荐指数
1
解决办法
3177
查看次数