我想创建只有垂直滚动的视图.事实证明,在iOs中很难做到.我已经完成了这个步骤:
1)在故事板中创建UIViewController;
2)在UIViewController中的View中添加ScrollView,并为每一侧添加0个约束.
启动我的应用程序后,所有工作,但:
1)我应该如何禁用水平滚动?我向右侧添加0约束我的scrollView + 0约束到我的uilabel右侧(因为你在屏幕上看到它没有附加到右边,它有不同的约束,但在属性我设置约束= 0)并且,正如我所想,标签文本应该在我的屏幕边界,但是当我启动应用程序时我可以向右滚动,即可用文本没有换行,我的scrollview只是调整大小以适应文本.我试图设置我的scrollView在代码:scrollView.contentSize = CGSize(UIScreen.mainScreen().bounds.width, height: 800),但没有帮助.
2)如果我滚动到很多,那么出现空白区域,这不是很酷,如何解决?
我正在阅读一个针对Android分析的新谷歌教程,这很奇怪,首先当我在我的gradle中添加这些字符串时:
classpath 'com.google.gms:google-services:1.3.0-beta1'
apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)
我无法同步我的项目(插件未找到错误).我不知道它是否重要.我只能添加compile 'com.google.android.gms:play-services-analytics:7.3.0'.第二,在教程中有一个步骤,我应该子类应用程序:
package com.google.samples.quickstart.analytics;
import android.app.Application;
import com.google.android.gms.analytics.GoogleAnalytics;
import com.google.android.gms.analytics.Logger;
import com.google.android.gms.analytics.Tracker;
/**
* This is a subclass of {@link Application} used to provide shared objects for this app, such as
* the {@link Tracker}.
*/
public class AnalyticsApplication extends Application {
private Tracker mTracker;
/**
* Gets the default {@link Tracker} for this {@link Application}.
* @return tracker
*/
synchronized public Tracker getDefaultTracker() {
if (mTracker == …Run Code Online (Sandbox Code Playgroud) 我有一个UITableView与包含图像的单元格.我想从服务器下载一个大图像并将其插入我的单元格.
我的UITableViewCell具有固定的高度并填充整个屏幕宽度.最好的解决方案是按比例调整图像大小以适应屏幕宽度,然后裁剪固定高度的区域,但我发现调整UIImage的大小真的很难,我不明白为什么.如果你可以帮助我,这将是非常好的.
无论如何,目前,我正试图在UITableViewCell中使用AspectFill模式(我已经尝试过AspectFit和ScaleToFill并且它不是我想要的),但由于某些原因,我的图像高于单元格高度:
我不明白我做错了什么.它不是自动布局,它是固定高度.它为什么不起作用?
美好的一天,我试图在谷歌播放中将屏幕尺寸限制为仅手机(即不是平板电脑).找到这篇文章后,我将其添加到我的清单文件中:
<compatible-screens>
<!-- all small size screens -->
<screen android:screenSize="small" android:screenDensity="ldpi" />
<screen android:screenSize="small" android:screenDensity="mdpi" />
<screen android:screenSize="small" android:screenDensity="hdpi" />
<screen android:screenSize="small" android:screenDensity="xhdpi" />
<!-- all normal size screens -->
<screen android:screenSize="normal" android:screenDensity="ldpi" />
<screen android:screenSize="normal" android:screenDensity="mdpi" />
<screen android:screenSize="normal" android:screenDensity="hdpi" />
<screen android:screenSize="normal" android:screenDensity="xhdpi" />
</compatible-screens>
Run Code Online (Sandbox Code Playgroud)
但现在看来,使用5.5 ++英寸手机的用户无法安装我的应用程序.接下来我也发现了这篇文章和图片:
我的第一个问题 - 是否可以将屏幕尺寸限制为特定的英寸值,或者我只能使用小型,普通型,大型和Xlarge等标签?
在某些时候,我决定通过更新清单将支持英寸大小增加到7:
<compatible-screens>
<!-- all small size screens -->
<screen android:screenSize="small" android:screenDensity="ldpi" />
<screen android:screenSize="small" android:screenDensity="mdpi" />
<screen android:screenSize="small" android:screenDensity="hdpi" />
<screen android:screenSize="small" android:screenDensity="xhdpi" /> …Run Code Online (Sandbox Code Playgroud) 美好的一天,我是ASP.NET的新手,我无法弄清楚为什么我的代码不起作用.我有模特:
using System.ComponentModel.DataAnnotations;
using System.Drawing;
using System.Globalization;
namespace WebApp.Models
{
public class News
{
public int NewsId { get; set; }
public string title { get; set; }
public string description { get; set; }
public virtual Picture picture { get; set; }
public int guid { get; set; }
}
public class Picture
{
public int PictureId { get; set; }
public byte[] image { get; set; }
public int width { get; set; }
public int height { …Run Code Online (Sandbox Code Playgroud) 我有 UItableview 和活动 UIRefreshControl 用于拉动刷新操作。因此,我尝试通过取消选择 Storyboard 中 tableview 的“bounce”属性来禁用弹跳(当我滚动 UITableView 时出现)。但是,当我执行此拉动刷新操作时,它也会停止工作。对此我能做什么?我应该仅手动禁用 UIRefreshControl 的底部弹跳和左顶部弹跳吗?
\n\n我的 viewDidLoad 方法:
\n\noverride func viewDidLoad() {\n super.viewDidLoad()\n\n self.refreshControl = UIRefreshControl()\n self.refreshControl!.attributedTitle = NSAttributedString(string: "\xd0\x9e\xd0\xb1\xd0\xbd\xd0\xbe\xd0\xb2\xd0\xbb\xd0\xb5\xd0\xbd\xd0\xb8\xd0\xb5")\n self.refreshControl!.addTarget(self, action: "refresh:", forControlEvents: UIControlEvents.ValueChanged)\n self.edgesForExtendedLayout = UIRectEdge.None;\n tableView.allowsMultipleSelectionDuringEditing = false;\n tableView.tableFooterView = UIView()\n // menu button\n if self.revealViewController() != nil {\n menuButton.target = self.revealViewController()\n menuButton.action = "revealToggle:"\n self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n 我想禁用UITableView底部反弹,我不能在情节提要中使用标准的“ bounce”属性,bcs UIRefreshControl需要顶部反弹才能工作。所以我尝试了这个解决方案:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (scrollView.contentOffset.y >= scrollView.contentSize.height - scrollView.frame.size.height) {
[scrollView setContentOffset:CGPointMake(scrollView.contentOffset.x, scrollView.contentSize.height - scrollView.frame.size.height)];
}
Run Code Online (Sandbox Code Playgroud)
}
如上图所示,UIRefreshControl没有被隐藏(如果UIRefreshControll被隐藏,则uitableview中只有3个单元格,底部有空白)。我试图通过将UIRefreshControl高度添加到我的方法中来解决此问题,但是它也没有帮助:
override func scrollViewDidScroll(scrollView: UIScrollView) {
if scrollView.contentOffset.y >= scrollView.contentSize.height - scrollView.frame.size.height - self.refreshControl!.frame.size.height {
scrollView.setContentOffset(CGPoint(x: scrollView.contentOffset.x, y: scrollView.contentSize.height - scrollView.frame.size.height + self.refreshControl!.frame.size.height), animated: false)
}
}
Run Code Online (Sandbox Code Playgroud)
我顶部有空白,RefreshControl停止工作:
我究竟做错了什么?谢谢。
PS我的viewDidLoad方法:
override func viewDidLoad() {
super.viewDidLoad()
self.refreshControl = UIRefreshControl()
self.refreshControl!.attributedTitle = NSAttributedString(string: "??????????")
self.refreshControl!.addTarget(self, action: "refresh:", forControlEvents: UIControlEvents.ValueChanged)
self.edgesForExtendedLayout = UIRectEdge.None;
tableView.allowsMultipleSelectionDuringEditing = false;
tableView.tableFooterView = UIView() …Run Code Online (Sandbox Code Playgroud) 我正在开发适用于 Android TV 的应用程序并使用 Leanback 库。
以谷歌为例,他们用来public class CardPresenter extends Presenter显示内容。问题是,我想显示标题中的所有文本,即不要剪切它。
我已经尝试过:
1) 通过以编程方式设置 LayoutParams 来解决此问题:cardView.findViewById(R.id.title_text).setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT));
2)我查看了 lb_image_card_view.xml 文件中的ImageCard。有趣的是,ID为“title_text”的TextView已经有android:layout_height="wrap_content"参数,但看起来不起作用?这是一个错误吗?
3)对于备份计划,我可以为 ImageCardView 创建自己的类,但这个解决方案似乎很难。
谢谢。
更新。
我使用了下面的答案,但我必须修改代码以获得更好的性能:
cardView.setOnFocusChangeListener((view, isFocused) -> {
if (isFocused) {
((TextView) cardView.findViewById(R.id.title_text)).setMaxLines(5);
}
else {
((TextView) cardView.findViewById(R.id.title_text)).setMaxLines(1);
}
});
Run Code Online (Sandbox Code Playgroud) 我正在开发新闻源,我正在使用uitableview来显示数据.我在其他线程中同步加载每个单元格数据并使用协议方法显示加载的数据:
func nodeLoaded(node: NSMutableDictionary) {
for var i = 0; i < nodesArray.count; ++i {
if ((nodesArray[i]["id"] as! Int) == (node["id"] as! Int)) {
nodesArray[i] = node
}
}
}
Run Code Online (Sandbox Code Playgroud)
问题是,当我滚动我的uitableview(同时加载数据时),我的一些单元重复(8行具有相同的内容,如第一行,或6行具有相同的内容,如第二行).当我滚动一段时间后(我想在加载数据后)然后一切都变得正常了.我寻找答案,发现我必须在cellForRowAtIndexPath检查单元格是否为nill,但是在swift中我的代码与目标C中的代码不同:
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell: NewsCell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! NewsCell
var node = nodesArray[indexPath.row] as! NSDictionary
if (node["needLoad"] as! Bool) {
dbHelper.getNode(node["id"] as! Int, hash: node["id"] as! Int, tableName: DbHelper.newsTableName, callback: self)
} else {
cell.id = node["id"] as! Int …Run Code Online (Sandbox Code Playgroud) 我在每个单元格中都有UITableView图像,我希望滚动顺畅.所以我在stackerflow上阅读了一些帖子,现在我在后台线程中加载我的图片:
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell: BuildingStatusCell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! BuildingStatusCell
cell.selectionStyle = UITableViewCellSelectionStyle.None
var node = nodesArray[indexPath.row] as! NSMutableDictionary
if !checkIfImagesLoaded(node[Api.pictures] as! NSMutableArray) {
cell.id = node[Api.buildingStatusId] as! Int
cell.date.text = node[Api.date] as? String
cell.count.text = String((node[Api.pictures] as! NSMutableArray).count)
cell.indicator.hidesWhenStopped = true
cell.indicator.startAnimating()
dbHelper.getBuildingStatusNode(node, callback: self)
} else {
cell.id = node[Api.buildingStatusId] as! Int
cell.date.text = node[Api.date] as? String
cell.count.text = String((node[Api.pictures] as! NSMutableArray).count)
dispatch_async(dispatch_get_global_queue(Int(QOS_CLASS_USER_INITIATED.value), 0)) {
var image = …Run Code Online (Sandbox Code Playgroud) ios ×6
swift ×6
uitableview ×5
android ×3
android-tv ×1
asp.net ×1
autolayout ×1
c# ×1
google-play ×1
iphone ×1
java ×1
objective-c ×1
screen-size ×1
swift2 ×1
uiimageview ×1
uiscrollview ×1