我有一个UIViewController在Interface Builder,和我添加UIScrollView的UIView.它具有contentOffset等于0.0 的属性,但是当我滚动UIScrollView到最底部并向另一个视图推送contentOffset更改时.
NSLog 给了我以下值:
//View just loaded
2013-09-09 16:19:27.455 my_app[24588:907] Scroll View content offset is 0.000000
//We came back from another view
2013-09-09 16:19:30.957 my_app[24588:907] Scroll View content offset is 108.000000
Run Code Online (Sandbox Code Playgroud)
这种行为的原因是什么?我刚刚UIScrollView在IB中添加了一个并且根本没有在代码中做任何事情.
在contentHeight滚动视图的比我的大self.view.height.在frame滚动视图中保持不变.
我想用水平滚动视图创建一个活动.滚动视图的内容将是三个不同的线性布局.这些线性布局中的每一个都应占据设备屏幕的整个宽度.因此,当活动开始时,只有一个线性布局占据屏幕的整个宽度,当用户向右滑动时,另一个线性布局将以全宽显示.(见图)
我不确定如何设置linearlayouts的宽度,以便它们适合屏幕的宽度.关于如何以一种好的方式解决这个问题的任何想法?

我正在寻找使用UIPageViewControllerXcode的故事板.我能找到的唯一例子就是如何使用单独的xib文件实现本教程UIPageViewcontroller.
但是,在本教程中,将UIPageViewController在扩展的类中以编程方式实例化UIViewController.这使得转换为故事板如何解释UIPageViewcontroller(这是一个单独的实例)变得复杂.
任何有关如何UIPageViewController使用Xcode的故事板创建功能的帮助将非常感激.
更新:我设法通过使用默认的pagecontroller模板在Xcode中创建一个新项目来解决此问题.它使用故事板,很容易遵循.
我正在创建一个带有360度全景图像的iPhone应用程序.全景图是UIScrollView中的CATiledLayer.
我试图在图像上实现无限滚动(仅水平).我通过继承UIScrollView并实现setContentOffset:和setContentOffset:animated来完成此操作:当用户拖动scrollview时,这非常有效.但是,当用户抬起手指并且滚动视图正在减速时,更改contentOffset会导致减速立即停止.
- (void)setContentOffset:(CGPoint)contentOffset
{
CGPoint tempContentOffset = contentOffset;
if ((int)tempContentOffset.x >= 5114)
{
tempContentOffset = CGPointMake(1, tempContentOffset.y);
}
else if ((int)tempContentOffset.x <= 0)
{
tempContentOffset = CGPointMake(5113, tempContentOffset.y);
}
[super setContentOffset:tempContentOffset];
}
Run Code Online (Sandbox Code Playgroud)
有没有办法在不影响减速的情况下更改contentOffset?
这里建议覆盖setContentOffset :(不是setContentOffset:animated :)修复了这个问题,但我似乎无法让它工作.
我也尝试过scrollRectToVisible:动画:没有成功.
任何关于如何解决这个问题的想法将不胜感激.谢谢!
编辑:
scrollViewDidScroll的代码:
-(void)scrollViewDidScroll:(PanoramaScrollView *)scrollView
{
[panoramaScrollView setContentOffset:panoramaScrollView.contentOffset];
}
Run Code Online (Sandbox Code Playgroud)
我也试过这个:
-(void)scrollViewDidScroll:(PanoramaScrollView *)scrollView
{
CGPoint tempContentOffset = panoramaScrollView.contentOffset;
if ((int)tempContentOffset.x >= 5114)
{
panoramaScrollView.contentOffset = CGPointMake(1, panoramaScrollView.contentOffset.y);
}
else if ((int)tempContentOffset.x == 0)
{
panoramaScrollView.contentOffset = CGPointMake(5113, panoramaScrollView.contentOffset.y);
}
}
Run Code Online (Sandbox Code Playgroud) 我的Android Manifest文件
<service android:name="com.google.android.gms.analytics.CampaignTrackingService" />
<receiver android:name="com.google.android.gms.analytics.CampaignTrackingReceiver"
android:exported="true" >
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)
我没有任何其他接收器.
测试:
~/development/sdk/platform-tools $ ./adb shell am broadcast -a com.android.vending.INSTALL_REFERRER -n com.myapp.myapplication/com.google.android.gms.analytics.CampaignTrackingService --es "referrer" "utm_source=testSource&utm_medium=testMedium&utm_term=testTerm&utm_content=testContent&utm_campaign=testCampaign"
Run Code Online (Sandbox Code Playgroud)
响应:
Broadcasting: Intent { act=com.android.vending.INSTALL_REFERRER cmp=com.myapp.myapplication/com.google.android.gms.analytics.CampaignTrackingService (has extras) }
Broadcast completed: result=0
Run Code Online (Sandbox Code Playgroud)
现在,当我运行应用程序时,我得到了 I/GAV3(17797): Thread[GAThread,5,main]: No campaign data found.
然后我尝试了自定义接收器:这是我的代码:
<service android:name="com.myapp.myapplication.ReferrerCatcher"/>
<receiver android:name="com.myapp.myapplication.ReferrerCatcher" android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)
我的接收器:
package com.myapp.myapplication;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import com.google.analytics.tracking.android.CampaignTrackingReceiver;
public class ReferrerCatcher extends …Run Code Online (Sandbox Code Playgroud) android google-analytics broadcastreceiver android-intent google-play
我正在尝试检测ScrollView何时完成滚动,以便稍微修改其位置.在我使用ACTION_UP检测用户何时举起手指之前,我意识到这不允许我使用"投掷",因为它会在完成之前修改滚动.
有没有办法检测ScrollView何时完成滚动?或者像ListView一样检测它的滚动状态?
关于如何实现这个的任何其他想法?
谢谢.
我在衬里布局中有一个滚动视图,这是我的布局文件
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<!-- Other widgets go here -->
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<!-- Scroll view content -->
</ScrollView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我希望ScrolView的高度取决于其内容 - 包装它,但是如果这个高度使整个布局高度超过屏幕尺寸,则应该将其固定以适应屏幕的高度.如何实现呢?
我尝试用scrollview包装我的relativelayout以在横向模式下使用但它不起作用.我也尝试用linearlayout包装我的相对布局,但它也不起作用.
这是xml,其中relativelayout包含在scrollview中:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#2d89ef">
<!--Some components here-->
</RelativeLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
这是我的完整xml:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#2d89ef">
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="Segoe UI Light"
android:gravity="center"
android:text="@string/app_name"
android:textColor="#FFFFFF"
android:textSize="25dp"
android:textIsSelectable="false"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp" />
<EditText
android:id="@+id/editText"
android:layout_width="275dp"
android:layout_height="wrap_content"
android:ems="10"
android:fontFamily="Segoe UI Light"
android:gravity="center_vertical"
android:hint="@string/username"
android:inputType="textPersonName"
android:textColor="@android:color/white"
android:textSize="16sp"
android:width="200dp"
android:layout_below="@+id/textView"
android:layout_centerHorizontal="true">
<requestFocus />
</EditText>
<EditText
android:id="@+id/editText2"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:ems="10"
android:fontFamily="Segoe UI Light"
android:gravity="center_vertical"
android:hint="@string/password"
android:inputType="textPassword"
android:textColor="@android:color/white"
android:textSize="16sp"
android:width="200dp"
android:layout_below="@+id/editText"
android:layout_alignRight="@+id/editText"
android:layout_alignLeft="@+id/editText" /> …Run Code Online (Sandbox Code Playgroud) 我有一个子类UIScrollView,并覆盖所有4个Touches函数.在那些倒是功能,
[[self nextResponder] Touches...]和[super Touches...]用于通过触摸事件.
我还有一个视图控制器,我也可以覆盖所有4个Touches功能.在Controller中,我设置self.view为:self.view = subclass of UIScrollview;
在iOS 5之前,当滚动视图上有触摸移动时,视图控制器的触摸功能可以接收所有触摸开始/移动/结束/取消呼叫.但是在iOS 5中,他们不能,只收到一个touchesBegan和一个touchesMove.
从代码日志中,UIScrollView始终调用子类中的触摸函数.
此外,如果我设置了subclass.enableUserInteraction=NO,将很好地调用视图控制器中的触摸功能.但我需要scrollview与用户进行交互,所以我无法将其设置为no.
我在iOS 5中错过了什么不同的东西?先感谢您.
我正在尝试制作一个具有“内边框”的响应式按钮(如果有意义的话),请参阅附图了解我正在谈论的内容。

我的一些按钮比其他按钮更宽,因为按钮文本更长,这就是响应部分的用武之地。我通过将按钮放入容器 div 中来创建此效果,代码如下:
超文本标记语言
<div class="ttw_button_container">
<a class="ttw_button">START THE JOURNEY</a>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS
.ttw_button_container {
background: #27d9b4;
width: 330px;
height: 50px;
margin: 0 auto;
}
a.ttw_button{
background: #27d9b4;
color: {{ settings.btn_text_color }};
border: 1px solid white;
padding: 6px 52px;
margin: 4px 0 0 0;
cursor: pointer;
font-weight: bold;
font-size: 19px;
text-transform: {{ settings.button_font_style }};
display: inline-block;
-webkit-transition: all 200ms ease 0s;
-moz-transition: all 200ms ease 0s;
-ms-transition: all 200ms ease 0s;
-o-transition: all 200ms ease 0s;
transition: all 200ms ease …Run Code Online (Sandbox Code Playgroud) 我正在 for 循环中提取元数据值,并且需要将它们显示在逗号分隔的列表中。
代码(为了可读性添加了空格):
{% if asset.metadata['field01'] %}{{asset.metadata['field01']}}{% endif %}
{% if asset.metadata['field02'] %}{{asset.metadata['field02']}}{% endif %}
{% if asset.metadata['field03'] %}{{asset.metadata['field03']}}{% endif %}
Run Code Online (Sandbox Code Playgroud)
目前这显示为:Field 01 ValueField 02 ValueField 03 Value,但我希望它显示为Field 01 Value, Field 02 Value, Field 03 Value
在每个 if 语句后手动键入,,会在最后一个值后留下一个逗号。
我有一个10edittexts英寸scrollview的 当第一个edittext聚焦时,它如下图所示。

当点击下一步时,它显示如下。
但我需要edittext自动滚动,如下图所示

请帮我解决这个问题。
我DiscountListTableViewController在我的应用程序中显示为一个单独的屏幕.但是还有另一个屏幕(PlaceDetailsViewController),我需要在底部显示相关的折扣.
目前,PlaceDetailsViewController.view有UIScrollView作为容器和我加入DiscountListTableViewController.tableView到这个UIScrollView.content容器中viewDidLoad的PlaceDetailsViewController.这样可以正常显示表格视图,但无法接收单元格点击.
我知道UITableView继承UIScrollView而且不知何故(但不限制).但是,从松散耦合的角度来看,每个组件的设计应该可以在其他地方独立使用,而且就DiscountListTableViewController我而言.
PlaceDetailsViewController组件只需要按DiscountListTableViewController原样,所以没有逻辑上的理由不能直接使用它.有什么建议?
android ×6
scrollview ×6
ios ×4
uiscrollview ×4
iphone ×3
objective-c ×2
cocoa-touch ×1
css ×1
dotliquid ×1
google-play ×1
html ×1
ios5 ×1
scrollbar ×1
shopify ×1
storyboard ×1
touches ×1
uitableview ×1
uiview ×1
xcode ×1